[英]What are the differences between -std=c++11 and -std=gnu++11?
What are the differences between -std=c++11
and -std=gnu++11
as compilation parameter for gcc and clang? -std=c++11
和-std=gnu++11
作为gcc和clang的编译参数有什么区别? Same question with c99
and gnu99
? 与
c99
和gnu99
相同的问题? I know about C++ and C standards, it's the differences in the parameters that interest me. 我了解C ++和C标准,这是我感兴趣的参数差异。
I've read somewhere that it has to do with some extensions but it is not clear to me which ones and how to choose between one or the other for a new project. 我已经阅读了某些与某些扩展有关的内容,但我不清楚哪些扩展以及如何在新项目中选择其中一个。
As you have found out yourself, the difference between the two options is whether GNU extensions that violates/extend the C++ standard are enabled or not. 正如您自己发现的那样,两个选项之间的区别在于是否启用了违反/扩展C ++标准的GNU扩展。 The GNU C++ extensions are described here .
这里描述了 GNU C ++扩展。 You can also use most of the GNU C extensions (described here ) in your C++ programs.
您还可以在C ++程序中使用大多数GNU C扩展( 在此处描述)。 It would be also useful to read about the
-Wpedantic
GCC option here . 在这里阅读
-Wpedantic
GCC选项也很有用。
Note that some extensions can still be in effect when using -std=c++11
, as long as they do not contradict the standard. 请注意,使用
-std=c++11
时,某些扩展仍然有效,只要它们与标准不矛盾即可。 For instance, when using the MinGW compiler, I need the extensions for a working Boost.Lexical_Cast
. 例如,当使用MinGW编译器时,我需要扩展工作的
Boost.Lexical_Cast
。 But, as long as you don't use any of them, you are better off sticking to the standard without extensions for maximum portability. 但是,只要你不使用它们中的任何一个,你最好坚持使用没有扩展的标准以获得最大的可移植性。 This might come in handy if you find yourself forced to change compiler.
如果您发现自己被迫更改编译器,这可能会派上用场。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.