-std=c++0x 和 -std=c++11 有什么区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24589105/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 00:46:20  来源:igfitidea点击:

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

c++eclipsec++11

提问by SangminKim

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

我知道这些标志适用于 Eclipse 中的 C++11。

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.

似乎他们都在正常使用 C++11。

回答by Daniel Frey

You should prefer -std=c++11.

你应该更喜欢-std=c++11.

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

(注意:我认为-std=c++11x您的问题中有错字)

The old -std=c++0xis only needed for older compiler versions that did not support -std=c++11and 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++10or 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.

-std=c++0x版本仅适用于不支持的旧编译器版本,-std=c++11他们选择该名称来表达当时即将推出的功能(和 ABI)的初步和不稳定性质C++11(当尚不清楚最终是否会成为C++10或 时C++12) . 在 C++11 标准正式发布之前,他们更改了一些细节以适应该标准不断变化的工作草案。

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.

如果您的编译器支持-std=c++11,则没有理由使用-std=c++0x. 关于兼容性:甚至可能存在差异和不兼容性,但这不仅与 的使用有关-std=c++0x,而且与编译器的特定版本有关。当编译器支持两者时,它们应该是相同的。

回答by Jordi

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

C++ 和 C 标准通常以它们发布的年份命名,这样更容易记住。

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.

例如,在 C++ 中,最初的标准发布于 1998 年,所以我们谈论的是 C++98,而当我们提到它于 2003 年发布的第一次更正时,我们谈论的是 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.

据称下一个标准将在 2008 年完成,但由于不确定,它被称为 C++0x,其中 x 代表 8 或 9。转移了,所以我们最终得到了 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!

尽管如此,对于下一个版本(C++1x),Bjarne Stroustrup 表示他打算在 5 年内完成(大约 2016 年)。目前,对核心语言(概念、模块和垃圾收集)进行了预想,重点似乎更多地放在扩展库(例如文件系统)上,但现在还为时过早,谁知道呢!