vendredi 27 octobre 2017

How to determine what C++ standard is the default for a C++ compiler?

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 or -std=gnu++11). A related question that is not typically addressed (at least as far as I can tell; see, for instance, the highly-upvoted comment by Dennis under the selected answer by Oskar N.) is how to determine what the default C++ standard that is being used by the compiler is.

I believe that it is possible to tell by looking at the man page (at least for g++), but I wanted to ask if this is correct and also if there are more definitive/concrete methods:

Under the description of -std, the man page lists all C++ standards, including the GNU dialects. Under one specific standard, it is rather inconspicuously stated, This is the default for C++ code. (there is an analogous statement for C standards: This is the default for C code.).

For instance, for g++/gcc version 5.4.0, this is listed under gnu++98/gnu++03, whereas for g++/gcc version 6.4.0, this is listed under gnu++14.

This would naturally seem to indicate the default standard, but it is written so inconspicuously that I am not entirely certain. If this is the case, perhaps this will be of use to others who have wondered about this very same question. Are there other convenient methods for other C++ compilers?

Aucun commentaire:

Enregistrer un commentaire