简体   繁体   English

-std = c ++ 11在g ++命令行中的位置

[英]Position of -std=c++11 in g++ command line

I am just curious if the position of the standard selection switch ( -std=c++11 for my case) is relevant in g++ command line or not. 我只是好奇标准选择开关的位置(对于我的情况是-std=c++11 )在g ++命令行中是否有意义。 The reason is that the following: 原因如下:

g++   -ftest-coverage -fprofile-arcs -std=c++11 
      -ansi -fpermissive -finline-functions -Wno-long-long
      -fvisibility-inlines-hidden -m64 -Wall -Wextra 
      -g -o CMakeFiles/common.dir/cryptoclass.cpp.o 
      -c /home/work/common/cryptoclass.cpp

does not compile, while the following: 不编译,而以下内容:

g++   -ftest-coverage -fprofile-arcs
      -ansi -fpermissive -finline-functions -Wno-long-long
      -fvisibility-inlines-hidden -m64 -Wall -Wextra 
      -g -o CMakeFiles/common.dir/cryptoclass.cpp.o 
      -std=c++11  -c /home/work/common/cryptoclass.cpp

does compile. 确实可以编译。 The only change is that the -std=c++11 was moved to the end of the switches. 唯一的变化是-std=c++11已移至开关的末尾。

g++ gives the following warning: g ++发出以下警告:

error: #error This file requires compiler and 
       library support for the ISO C++ 2011 standard. 
       This support is currently experimental, and must 
       be enabled with the -std=c++11 or -std=gnu++11 compiler options.

Version: 版:

g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4

As per documentation , -ansi option enables the c++-98/c++-03 standard. 根据文档-ansi选项启用c ++-98 / c ++-03标准。

If you set multiple standard options, the latter option overrides the former. 如果设置多个标准选项,则后一个选项将覆盖前一个选项。 Same applies to other mutually exclusive options such as optimization levels. 同样适用于其他互斥选项,例如优化级别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM