It is frequently mentioned that the -std
flag should be used to specify the standard that one wishes to use when compiling a C++ program (e.g., -std=c++11
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:
If you compile omitting the -std=c++xx
flag, you should be able to detect the default version of language used.