Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check c++ version in microsoft visual studio 2017

I am trying to check the version of c++ i have with the following code.

if (__cplusplus == 201703L) std::cout << "C++17\n";
        else if (__cplusplus == 201402L) std::cout << "C++14\n";
        else if (__cplusplus == 201103L) std::cout << "C++11\n";
        else if (__cplusplus == 199711L) std::cout << "C++98\n";
        else std::cout << "pre-standard C++\n";

the output is C++98 version , but i am definitely able to use c++11 features so i think i am not getting the correct version from the code.

How can i check which version of c++ i am using ?

like image 236
Summit Avatar asked Feb 04 '20 06:02

Summit


People also ask

How do I check Visual C version?

To check if Visual C++ redistributables are installed, open Add and Remove Programs and look for the Microsoft Visual C++ Redistributable. If installed, you see "Microsoft Visual C++ 2015-2019 Redistributable (x64) - 14.22. 27821".

What version of C does Visual Studio use?

In versions of Visual Studio 2019 before version 16.11, /std:c++latest is required to enable all the compiler and standard library features of C++20. For a list of supported language and library features, see What's New for C++ in Visual Studio.

What version of C++ is Visual Studio 2017?

Visual Studio 2017 version 15.3/std:c++17 enables the set of C++17 features implemented by the compiler.

Is there C in Visual Studio?

Visual Studio Code is a lightweight, cross-platform development environment that runs on Windows, Mac, and Linux systems. The Microsoft C/C++ for Visual Studio Code extension supports IntelliSense, debugging, code formatting, auto-completion.


2 Answers

Easier way to check it than writing a program is under Project (right-click your project name in solution explorer) > Properties > C/C++ > Language > C++ Language Standard

And you can also change it there.

I know it thanks to this answer.

like image 65
FireFragment Avatar answered Oct 26 '22 14:10

FireFragment


From https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/

You need to compile with the /Zc:__cplusplus switch to see the updated value of the __cplusplus macro.

Note that this was added in MSVC 2017 (version 15.7 Preview 3), it's not available in older versions.

like image 30
Some programmer dude Avatar answered Oct 26 '22 16:10

Some programmer dude