默认情况下,在 Ubuntu 上,当我尝试像这样使用 g++ 编译时:
g++ -o name file.cpp
有时它会响应“ISO C++ 禁止...”
如果我不想用 ISO 编译,我应该使用什么标志?
最佳答案
使用
g++ -std=c++0x
或
g++ -std=gnu++0x
注意:如果您专有启用扩展,您的代码将变得不那么便携。
C++11 features are available as part of the "mainline" GCC compiler in the trunk of GCC's Subversion repository and in GCC 4.3 and later. To enable C++0x support, add the command-line parameter -std=c++0x to your g++ command line. Or, to enable GNU extensions in addition to C++0x extensions, add -std=gnu++0x to your g++ command line. GCC 4.7 and later support -std=c++11 and -std=gnu++11 as well.
关于c++ - 避免编译 ISO C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14692008/