I am beginner in cpp.
I had a old cpp which version i dont know. I ran the following to check the version.
int main()
{
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";
return 0;
}
Which outputs
c++14
After this, i tried to upgrade c++ version to latest c++ 20. Which i learned that each compilers support all different parts of c++. I downloaded mingw64 10.2
and added PATH
variables.
If i run g++ --version
, it correctly shows g++ version
. However above code still prints that i am using c++14
.
What am I missing?
You can set the C++ standard in gcc
with the command line argument -std
. Some of the supported standards are -std=c++11
, -std=c++14
, -std=c++17
, -std=c++20
.