Sunday, February 19, 2012

C++'11: __cplusplus macro updated

The macro __cplusplus in now defined to have a value of 201103L. This is outlined in section 16.8 [cpp.predefined] of the standard. This value is expected to be updated in each release. As the standards document says:
"It is intended that future versions of this standard will replace the value of this macro with a greater value. Non-conforming compilers should use a value with at most five decimal digits."
If you use GCC though, be aware that they just recently fixed their bug that caused the value to be always set to 1 instead of the previous standards value 199711L. See their bug report here for more details and some interesting insight into why something as simple as #define __cplusplus 199711L is not always so simple.

No comments:

Post a Comment