c++ - 避免编译 ISO C++

标签 c++ compilation compiler-errors

默认情况下,在 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.

参见 http://gcc.gnu.org/projects/cxx0x.html

关于c++ - 避免编译 ISO C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14692008/

相关文章:

haskell - Haskell 中的多个源文件

sql - VBS脚本执行SQL语句?

java - Visual Basic,预期语句结束 - 数组?

c++ - 将角度映射到 RGB 颜色

c++ - 多次插入 (<<) 与连接输出 (+)

c++ - 为什么 GetExitCodeThread() 在这里返回 FALSE?

maven - Maven无法编译

c++ - 默认构造函数编译错误,预期的ID不合格

c++ - 如何设置从 CreateProcess 创建的进程的搜索路径

c++ - 堆栈推送导致严重错误