Is C++11 available in Visual Studio 2017?

前端 未结 4 1220
轮回少年
轮回少年 2020-12-16 14:04

I am currently using Visual Studio Community 2017. From looking at the C++ Language Standards in the project properties, they only provide C++14 and C++17. Since my code was

相关标签:
4条回答
  • 2020-12-16 14:22

    C++ is an evolving standard - after 2003 there was 2011 (C++11) then 2014 (C++14) and now we have 2017 (C++17) and we're working towards 2020 (C++20). They're upward compatible.

    Look here for Microsoft Visual C++ support for the various standards.

    0 讨论(0)
  • 2020-12-16 14:23

    Microsoft I think has declared that

    Note that there is no plan to add a C++11 switch. link

    So there's not an explicit switch

    0 讨论(0)
  • 2020-12-16 14:36

    As an update to this, VS 2017, Update 9.4 (releasd Dec 2018) is now fully C++17 compliant.

    0 讨论(0)
  • 2020-12-16 14:44

    The Visual C++ 2017 compiler is C++11/C++14 compliant with a few specific exceptions:

    • Expression SFINAE is implemented, but not complete.
    • Full C99 preprocessor support is limited due to some bugs with variadic macros
    • Two phase name lookup is in VS 2017 (15.3 update) but is incomplete and only active when using /permissive-

    The compiler does not offer a specific C++11 mode and defaults to C++14, but that standard is fully inclusive of C++11. C++17 support is in progress, and requires you use the /std:c++17 or /std::c++latest switch.

    std::stoi requires you include the appropriate header, specifically <string>> Either you forgot to include that header -or- you didn't deal with the namespace resolution (either explicitly as std:: or via using namespace std;)

    See C++17 Features And STL Fixes In VS 2017 15.3 for the latest status of C++11/C++14/C++17 standards conformance as of the VS 2017 (15.3 update)

    UPDATED: Now that you have posted your code, I see that the problem has nothing to do with which standard is supported. Your problem is that you don't know the secrets of how Precompiled Headers work.

    Change:

    #include <string>
    #include "stdafx.h"
    

    to:

    #include "stdafx.h"
    #include <string>
    

    -or- add #include <string> to the precompiled header stdafx.h directly.

    See Creating Precompiled Header Files

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