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

前端 未结 2 588
感情败类
感情败类 2021-01-01 20:13

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

相关标签:
2条回答
  • 2021-01-01 20:55

    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!

    0 讨论(0)
  • 2021-01-01 20:59

    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.

    0 讨论(0)
提交回复
热议问题