Hubertm998
Hubertm998

Reputation: 21

How to set standard C++ 2003 in CMake

I'm looking for solution how to set standard of C++ to 2003 in cmake. I can find a lot of information how to do it on later versions like 11, 17 and so on. But for 2003 version I couldn't find it. Does someone knows how to set it? I found also how to do it by adding flag to every cmake list that project contains. The problem is that I have a lot of cmake lists in my project and I want to add it once in main cmake lists. Thanks in advance for help.

Upvotes: 2

Views: 1321

Answers (1)

starball
starball

Reputation: 52215

See the docs for CMAKE_CXX_STANDARD

Supported values are: [98, 11, 14, 17, 20, 23].

03 is not supported.


Notes:

Note that while gcc supports -std=c++03 as a flag, it is just an alias for -std=c++98. So the two flags have the same effect and it doesn't make a difference which of the two you use:

The original ISO C++ standard was published as the ISO standard (ISO/IEC 14882:1998) and amended by a Technical Corrigenda published in 2003 (ISO/IEC 14882:2003). These standards are referred to as C++98 and C++03, respectively. GCC implements the majority of C++98 (export is a notable exception) and most of the changes in C++03. To select this standard in GCC, use one of the options -ansi, -std=c++98, or -std=c++03; to obtain all the diagnostics required by the standard, you should also specify -pedantic (or -pedantic-errors if you want them to be errors rather than warnings).

MSVC does not provide flags for selecting standards older than C++14 (ctrl+F for "/std").

Upvotes: 3

Related Questions