Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

gcc

c++14

I installed 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. Will the compiler work in the same way and generate exactly the same executable for both options?

like image 498
ysrhung Avatar asked Mar 03 '15 06:03

ysrhung


People also ask

What is STD C ++ 1y?

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. There may be some minute differences between the two, but c++14 is the ISO standard. In short, use c++14 .

What version of C does GCC use?

Default gcc command is the GNU dialect of ISO C90 (including some C99 features). This is the default for C code.

What C++ version does GCC support?

GCC supports the original ISO C++ standard published in 1998, and the 2011, 2014, 2017 and mostly 2020 revisions. The original ISO C++ standard was published as the ISO standard (ISO/IEC 14882:1998) and amended by a Technical Corrigenda published in 2003 (ISO/IEC 14882:2003).

Does GCC 4.9 support C++14?

0 released, full of improved C++11 and C++14 features. GCC 4.9. 0 is now available, with further improved C++11 and C++14 conformance.


2 Answers

C++ 14 is the latest ISO standard, and should be used unless you need some gcc non standard feature.

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. There may be some minute differences between the two, but c++14 is the ISO standard.

In short, use c++14.

like image 157
Matt Avatar answered Oct 12 '22 17:10

Matt


In case of gcc 4.9.2 mentioned by you there is no difference between c++14 and c++1y. But for the earlier gcc version, e.g. gcc 4.8.1 there is no c++14 option

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.

like image 28
αλεχολυτ Avatar answered Oct 12 '22 16:10

αλεχολυτ