The meta question proposes that the c++98 and c++03 tags should be made synonyms. The question asker followed it up with Is value initialization part of the C++98 standard? If not, why was it added in the C++03 standard?, an excellent question which sheds light on the addition of value initialization to C++03. Consider this question to be a follow-up to the latter.
The OP asserts that modern compilers do not bother distinguishing between C++98 and C++03. This was surprising to me, as it turns out to be the case for three modern compilers. Although this question could boil down to "RTFM", my searches have not found anything conclusive.
GCC
Their standards page:
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; ...
Furthermore, their dialect options page says:
In C++ mode, [ansi] is equivalent to -std=c++98.
And group "c++98" and "c++03" together:
The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
additional defect reports. Same as -ansi for C++ code.
This seems to imply there is no way to turn on only C++98 mode.
Clang
The only thing I found find for Clang was on their manual, it says under C++ Language Features:
clang fully implements all of standard C++98 except for exported
templates (which were removed in C++11), ...
With no mention of C++03. It also states:
clang supports the -std option, which changes what language mode clang
uses. The supported modes for C are c89, gnu89, c94, c99, gnu99, c11,
gnu11, and various aliases for those modes. If no -std option is
specified, clang defaults to gnu11 mode. Many C99 and C11 features are
supported in earlier modes as a conforming extension, with a warning.
This is of course for their C compiler, I was not able to find any documentation on the C++ compiler, such as which options are valid to pass to -std
. I simply assume that Clang mirrors GCC's dialect options (for example, C++03 is valid on Clang), although without proof I cannot state so conclusively.
MSVC
As far as I know, MSVC doesn't allow you to change language standards like the two above do. A search for "C++98" on MSDN doesn't turn up anything. It appears that they implement C++98/C++11, for example as stated by Herb Sutter.
Questions
Although these questions sound obvious, the meta question has made me realize that it is not so obvious.
Is there a way to make GCC only conform to C++98? Enforcing the C++98 standard in gcc simply links to the same documentation I did, without any further consideration on whether it really is conforming against C++98.
Does Clang conform to C++98 or do they actually conform to C++03? Where can I find the relevant documentation for this?
Same for MSVC. Is there a way to change language standards in MSVC to conform only against C++98?
Answer
Is there a way to make GCC only conform to C++98?
No. You already thoroughly covered the available flags in your question, and none of them can do this.
Does Clang conform to C++98 or do they actually conform to C++03? Where can I find the relevant documentation for this?
Clang implements C++03 minus export
, just like GCC:
Clang implements all of the ISO C++ 1998 standard (including the defects addressed in the ISO C++ 2003 standard) except for export (which was removed in C++11).
Same for MSVC. Is there a way to change language standards in MSVC to conform only against C++98?
No. As you say, you cannot specify the C++ version in MSVC. There is a list of compiler flags and that is not the function of any of them.
The whole point of C++03 was to make corrections to C++98 and thus to effectively replace it outright, rather than to follow it as a new unit. It does not make sense to want to "revert" those fixes. That would be like asking Windows 7 SP2† to boot into Windows 7 SP1 mode. It just isn't a model that anyone would want to support.
† Fictional.
No comments:
Post a Comment