简体   繁体   English

-std = c ++ 11和-std = gnu ++ 11之间有什么区别?

[英]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 ? c99gnu99相同的问题? 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.

相关问题 C++ std=c++11 和 std=gnu++11 之间的标准正则表达式区别 - C++ standard regex difference between std=c++11 and std=gnu++11 g ++-警告:扩展的初始化程序列表仅在-std = c ++ 11或-std = gnu ++ 11中可用 - g++ - warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 非静态数据成员初始值设定项仅适用于 -std=c++11 或 -std=gnu++11 - Non-static data member initializers only available with -std=c++11 or -std=gnu++11 警告:扩展初始值设定项列表仅适用于 -std=c++11 或 -std=gnu++11 [默认启用] - warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default] “扩展初始化列表仅适用于 -std=c++11 或 -std=gnu++11”,我收到此错误 - “extended initializer lists only available with -std=c++11 or -std=gnu++11”, I'm Getting this error 使用-std = gnu ++ 11时发现了哪些已知的性能差异 - What known performance differences are found when using -std=gnu++11 CUDA 8使用-std = gnu ++ 11编译错误 - CUDA 8 compile errors with -std=gnu++11 如何在 IMPINJ Reader R420 的 octane etk 示例嵌入文件的给定 make 文件中添加 -std=c++11 或 -std=GNU++11? - How to add -std=c++11 or -std=GNU++11 in the given make file of octane etk sample embedded file of IMPINJ Reader R420? 使用-std = gnu ++ 11开关进行编译时std :: equal错误 - std::equal error while compiling with -std=gnu++11 switch Qt 5.7将-std = gnu ++ 11添加到我的编译器标志中,clobbering -std = c ++ 14 - Qt 5.7 adding -std=gnu++11 to my compiler flags, clobbering -std=c++14
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM