简体   繁体   English

gcc编译选项之间的区别std = c ++ 1y和std = c ++ 14

[英]Difference between gcc compile options std=c++1y and std=c++14

I installed gcc 4.9.2. 我安装了gcc 4.9.2。 I compiled the program using the following command: 我使用以下命令编译了程序:

/root/gcc-4.9.2/bin/g++ -std=c++1y testing.cpp

Note that in addition to the option -std=c++1y , there is another option -std=c++14 . 请注意,除了选项-std=c++1y ,还有另一个选项-std=c++14 Will the compiler work in the same way and generate exactly the same executable for both options? 编译器是否以相同的方式工作并为两个选项生成完全相同的可执行文件?

C++ 14 is the latest ISO standard, and should be used unless you need some gcc non standard feature. C++ 14是最新的ISO标准,除非您需要一些gcc非标准功能,否则应该使用它。

c++1y is a name that was used to refer to the c++14 standard before it was completed, so it is most likely adhering to a draft of the standard, but not the actual standard itself. c++1y是在完成之前用于引用c ++ 14标准的名称,因此它很可能遵循标准草案,而不是实际标准本身。 There may be some minute differences between the two, but c++14 is the ISO standard. 两者之间可能存在一些微小差异,但c++14是ISO标准。

In short, use c++14 . 简而言之,使用c++14

In case of gcc 4.9.2 mentioned by you there is no difference between c++14 and c++1y . 对于你提到的gcc 4.9.2, c++14c++1y之间没有区别。 But for the earlier gcc version, eg gcc 4.8.1 there is no c++14 option 但是对于早期的gcc版本,例如gcc 4.8.1, 没有c++14选项

 g++: error: unrecognized command line option '-std=c++14' 

because the year of standard acceptance was not known yet. 因为标准验收年份还不知道。 In such cases using the -std=c++1y option is only solution to enable some parts of oncoming c++14 standard. 在这种情况下,使用-std=c++1y选项只是启用即将推出的c ++ 14标准的某些部分的解决方案

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

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