How to determine what C++ standard is the default for a C++ compiler?
Add to max66's answer. There is no need to compile and execute the program. The same information can be grepped through the preprocessed output using:
g++ -x c++ -E -dM -< /dev/null | grep __cplusplus
The values of the __cplusplus macro gives the value of the standard.
What about compiling and executing the following trivial program ?
#include <iostream>
int main()
{ std::cout << __cplusplus << std::endl; }
The value printed should say the version used:
- 199711 for C++98,
- 201103 for C++11
- 201402 for C++14
- 201703 for C++17
If you compile omitting the -std=c++xx
flag, you should be able to detect the default version of language used.