Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between -std=c++0x and -std=c++11

Tags:

c++

c++11

eclipse

I know those flags are for C++11 in Eclipse.

But I don't know what is difference and which one is more preferred.

It seems that they both are working with C++11 normally.

like image 763
SangminKim Avatar asked Jul 05 '14 17:07

SangminKim


2 Answers

You should prefer -std=c++11.

(Note: I assume -std=c++11x is a typo in your question)

The old -std=c++0x is only needed for older compiler versions that did not support -std=c++11 and they chose that name to express the preliminary and unstable nature of features (and the ABI) of the then upcoming C++11 (and when it was still unclear whether that would eventually become C++10 or C++12). They changes some of the details adapting to the changing working drafts of the standard at the time before the C++11 standard was officially released.

If your compiler supports -std=c++11, there is no reason to use -std=c++0x. Concerning compatibility: There might even be differences and incompatibilities, but these are not just bound to the use of -std=c++0x, but to specific versions of the compiler. When the compiler supports both, they should be identical.

like image 81
Daniel Frey Avatar answered Sep 16 '22 11:09

Daniel Frey


C++ and C Standards are usually named after the year they are published in, which makes it easier to remember by.

For example, in C++, the original Standard was published in 1998, so we talk about C++98, and when we refer to its first correction, published in 2003, we talk about C++03.

It had been purported that the next Standard after would be done for 2008, but since it was uncertain, it was dubbed C++0x, where the x stood for either 8 or 9. In practice though, as we all know, the planning shifted and so we end-up with C++11.

Still, for the next version (C++1x), Bjarne Stroustrup stated his intent to do it in 5 years (so about 2016). For now, there are changes envisionned to the core language (concepts, modules and garbage collection), and the focus seems to be more on extending the library (filesystem for example), but it's still early so who knows!

like image 45
Jordi Avatar answered Sep 17 '22 11:09

Jordi