Why is it that although all other standard C++ macros are prefixed and suffixed by a double underscore, that __cplusplus
does not follow suit?
I've looked everywhere I can think of to no success.
Why is it that although all other standard C++ macros are prefixed and suffixed by a double underscore, that __cplusplus
does not follow suit?
I've looked everywhere I can think of to no success.
According to this, cfront (the original C++ compiler) used c_plusplus
instead of __cplusplus
.
The decision to use c_plusplus
seems to be arbitrary (and it ignores the "reserved identifiers" convention, if it existed at that time at all).
I assume __cplusplus
was later chosen to make the identifier reserved, while minimizing the difference compared to the original macro name.
.
all other standard C++ macros being both all uppercase and prefixed and suffixed by a double underscore
As noted in comments, not all of them are. In the recent years, the commitette seemed to favor lowercase names instead (when adding __has_include
and __cpp_*
feature test macros).
This should be of no concern to you. Any name beginning with __
(double underscore) is reserved for implementation, so __cplusplus
is ok.
Also, it is wrong to assume that all predefined macros in C++ are upper case. For example, __unix__
is lower-case, as well as bunch of other standard macros listed here: https://en.cppreference.com/w/cpp/preprocessor/replace