[ACCEPTED]-Is a C++ preprocessor identical to a C preprocessor?-c-preprocessor
The C++03 preprocessor is (at least intended 17 to be) similar to the C preprocessor before 16 C99. Although the wording and paragraph 15 numbers are slightly different, the only 14 technical differences I'm aware of between 13 the two are that the C++ preprocessor handles 12 digraphs and universal character names, which 11 are not present in C.
As of C99, the C preprocessor 10 added some new capabilities (e.g., variadic 9 macros) that do not exist in the current 8 version of C++. I don't remember for sure, but 7 don't believe that digraphs were added.
I 6 believe C++0x will bring the two in line 5 again (at least that's the intent). Again, the 4 paragraph numbers and wording won't be identical, but 3 I believe the intent is that they should 2 work the same (other than retaining the 1 differences mentioned above).
They are supposed to be the same: C++98 2 and C++03 should match C90, and C++0x should 1 match C99. There may be bugs in the wording, though.
Predefined macros differ between the preprocessors, mostly 4 for obvious language feature differences. E.g. compare:
- C99 N1256 draft 6.10.8 "Predefined macro names"
- C++11 N3337 draft 16.8 "Predefined macro names"
In 3 particular:
- C requires you not to define
__cplusplus
, C++ uses it to represent the version - C uses
__STDC__
to represent the version, C++ says is implementation defined and uses__cplusplus
instead - C has
__STDC_IEC_559__
and__STDC_IEC_559_COMPLEX__
to indicate floating point characteristics, C++ does not and seems replace that with the per typestd::numeric_limits<float>::is_iec559
constants - C does not have the macros prefixed with
__STDCPP
:_STDCPP_STRICT_POINTER_SAFETY__
and__STDCPP_THREADS__
As mentioned by DevSolar, C11 2 added many more defines which are not part 1 of C++11.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.