简体   繁体   English

为什么Visual Studio社区2017 C ++标准C ++ 98?

[英]Why is the Visual Studio Community 2017 C++ standard C++98?

Yesterday I upgraded to the latest VS Community 2017 (the previous one was installed last year) and wanted to check the C++ standard. 昨天我升级到最新的VS社区2017(前一个是去年安装的),并想检查C ++标准。 So I run the following code that checks it, and as it turns out, I have C++98: 所以我运行以下代码来检查它,结果证明,我有C ++ 98:

#include<iostream>
using namespace std;
int main()
{
    cout << __cplusplus << endl;
    system("pause");
}

Which outputs 哪个输出

199711 199711

Why don't I have the latest C++ standard? 为什么我没有最新的C ++标准?

代码,输出和vs版本的屏幕截图

The value of __cplusplus is temporarily intentionally non-conformant by default for current versions of Visual Studio in order to avoid breaking existing code. 对于当前版本的Visual Studio, __cplusplus的值暂时故意不符合要求,以避免破坏现有代码。 It does not mean your compiler does not support any C++11 (or newer) features. 这并不意味着您的编译器不支持任何C ++ 11(或更新)功能。

Quoting from MSVC now correctly reports __cplusplus : MSVC引用现在可以正确报告__cplusplus

/Zc:__cplusplus / ZC:__ CPLUSPLUS

You need to compile with the /Zc:__cplusplus switch to see the updated value of the __cplusplus macro. 您需要使用/Zc:__cplusplus开关进行编译,以查看__cplusplus宏的更新值。 We tried updating the macro by default and discovered that a lot of code doesn't compile correctly when we change the value of __cplusplus . 我们尝试默认更新宏,并发现当我们更改__cplusplus的值时,很多代码无法正确编译。 We'll continue to require use of the /Zc:__cplusplus switch for all minor versions of MSVC in the 19.xx family. 对于19.xx系列中的所有次要版本的MSVC,我们将继续要求使用/Zc:__cplusplus开关。

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

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