g ++默认cpp标准

问题描述

$ g++ -dM -E -x c++  /dev/null | grep -F __cplusplus

#define __cplusplus 201402L
$ g++ --version
g++ (GCC) 9.3.0
copyright (C) 2019 Free Software Foundation,Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or fitness FOR A PARTIculaR PURPOSE.

->根据上面的输出,我应该使用c ++标准14的g ++,所以如果我不传递-std = c ++ 17之类的东西,那么它应该使用cpp14,不是吗?

/* C++11 and C++14 */
auto i {10}; // i has type std::initializer_list<int> !!!

/* C++17 and later */
auto i {10}; // i has type int

但是 当我尝试

auto i{10};
    cout << typeid(i).name() << endl;

我知道了

$ ./a.exe        
i

这表明我已被选择为int而不是std :: initializer_list类型

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)