How to “activate” c++11 standard in visual studio 2010?

后端 未结 4 1664
走了就别回头了
走了就别回头了 2021-01-12 01:47

I am new to c++ programming and I need to use the Thread class in my VS 2010 project. I\'ve found this reference, but when I try the following:

#include <         


        
相关标签:
4条回答
  • 2021-01-12 02:27

    The Visual C++ compiler is not fully C++11 compatible. C++11 features had been supported since Visual Studio 2010 and added incrementally. Not even the next version of Visual Studio will provide full C++11 compatibility. A matrix of C++11 features available in different versions of Visual Studio can be found here:

    • C++0x Core Language Features In VC10: The Table
    • C++11 Features in Visual C++ 11
    • C++11/14 STL Features, Fixes, And Breaking Changes In VS 2013
    0 讨论(0)
  • 2021-01-12 02:28

    std::thread is obviously not in VS 2010. I think it was added with VS 2012, which is also supported by this question and answer. Is there any specific reason you're using 2010 rather than the latest version, 2013, which supports far more part of C++11?

    Also to note: Contrary to GCC, MSVC doesn't have an "opt-in" for newer standards. It just supports them out of the box as far as implemented.

    0 讨论(0)
  • 2021-01-12 02:35

    C++11 is enabled by default, but there is not many features implemented in VS 2010. C++11 standard library is missing many headers in VS 2010. Here is a comparison of a last few VS releases regarding the C++11 support.

    0 讨论(0)
  • 2021-01-12 02:39

    Here's what I've found by myself.

    To "activate" c++11 in visual studio you need to set "Platform Toolset" in project->properties to v110 or above. So that's how visual studio will understand that it should use c++11 features.

    BUT!

    The Visual C++ compiler is not fully C++11 compatible. C++11 features had been supported since Visual Studio 2010 and added incrementally. Not even the next version of Visual Studio will provide full C++11 compatibility.

    Marius Bancila

    So it worked for <thread> (and <future>) in visual studio 2012.

    As I suggest it's impossible to set Platform Toolset above v100 in vs2010, so it's impossible to "activate" c++11 in vs2010.

    Conclusion: to use c++11 standart features in visual studio you will need to use 2012 and higher version which supports Platform Toolset v110 and above.

    Correct me please if I'm wrong!

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