为什么 Visual Studio Community 2017 C++ 标准是 C++98?
Why is the Visual Studio Community 2017 C++ standard C++98?
昨天升级到最新的VS Community 2017(上一个是去年装的),想看看C++标准。所以我 运行 下面的代码检查它,事实证明,我有 C++98:
#include<iostream>
using namespace std;
int main()
{
cout << __cplusplus << endl;
system("pause");
}
输出
199711
为什么我没有最新的 C++ 标准?
__cplusplus
的值暂时故意与 Visual Studio 当前版本的默认值不一致,以避免破坏现有代码。这并不意味着您的编译器不支持任何 C++11(或更新版本)功能。
引用自MSVC now correctly reports __cplusplus:
/Zc:__cplusplus
You need to compile with the /Zc:__cplusplus
switch to see the updated value of the __cplusplus
macro. 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
. We’ll continue to require use of the /Zc:__cplusplus
switch for all minor versions of MSVC in the 19.xx family.
昨天升级到最新的VS Community 2017(上一个是去年装的),想看看C++标准。所以我 运行 下面的代码检查它,事实证明,我有 C++98:
#include<iostream>
using namespace std;
int main()
{
cout << __cplusplus << endl;
system("pause");
}
输出
199711
为什么我没有最新的 C++ 标准?
__cplusplus
的值暂时故意与 Visual Studio 当前版本的默认值不一致,以避免破坏现有代码。这并不意味着您的编译器不支持任何 C++11(或更新版本)功能。
引用自MSVC now correctly reports __cplusplus:
/Zc:__cplusplus
You need to compile with the
/Zc:__cplusplus
switch to see the updated value of the__cplusplus
macro. 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
. We’ll continue to require use of the/Zc:__cplusplus
switch for all minor versions of MSVC in the 19.xx family.