当我执行
g++ main.cpp
我得到输出
main.cpp:9:17: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
main.cpp:10:15: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
main.cpp:11:16: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
main.cpp:12:14: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
main.cpp:13:13: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
现在如果我跑
g++ -std=c++11 main.cpp
警告消失了,但我不想明确指定已启用的内容。我犹豫要不要创建一个简单的 bash 别名,因为如果我没记错的话,gcc 已经是某种别名了。无论如何这样做是否安全,或者是否有正确的方法可以在配置文件或其他内容中解决此问题?我正在使用默认存储库的 Ubuntu 12.10 x64 上运行。