My compiler expands it to 199711L. What does that mean? I read that __cplusplus > 199711L signifies C++11. What are the possible expansions of this macro and what does it signify?
-
It signifies the current current language version – Ravi Prakash Jun 23 '21 at 06:14
-
Consider using [GNU autoconf](https://www.gnu.org/software/autoconf/). Read also your relevant [C++ standard](https://isocpp.org/std/the-standard) – Basile Starynkevitch Jul 31 '23 at 20:00
4 Answers
The 199711L stands for Year=1997, Month = 11 (i.e., November of 1997) -- the date when the committee approved the standard that the rest of the ISO approved in early 1998.
For the 2003 standard, there were few enough changes that the committee (apparently) decided to leave that value unchanged.
For the 2011 standard, it's required to be defined as 201103L, (again, year=2011, month = 03) again meaning that the committee approved the standard as finalized in March of 2011.
For the 2014 standard, it's required to be defined as 201402L, interpreted the same way as above (February 2014).
For the 2017 standard, it's required to be defined as 201703L (March 2017).
For the 2020 standard, the value has been updated to 202002L (February 2020).
For the 2023 standard, the value has been updated to 202302L (February 2023).
Before the original standard was approved, quite a few compilers normally defined it to 0
(or just an empty definition like #define __cplusplus
) to signify "not-conforming". When asked for their strictest conformance, many defined it to 1
.
I almost forgot to mention, but one more tidbit about ancient compilers: a few of the earliest versions of cfront (and probably a few others copying it) defined c_plusplus
instead of __cplusplus
. I don't recall it's being defined to any meaningful value though.

- 476,176
- 80
- 629
- 1,111
-
2003 was a "technical revision", not really a standard. It just introduced the "TR3" material which was never part of the standard. – Michael J Jun 15 '12 at 15:48
-
@MichaelJ: ["ISO/IEC JTC1/SC22/WG21 has produced the standard ISO/IEC 14882:2003 on the programming language C++. It was published 2003-10-16."](http://www.open-std.org/jtc1/sc22/WG21/docs/standards). Note that this is the result of a TC (Technical corrigendum) not a TR (technical report). A TR is a separate document, not a revision to the standard. – Jerry Coffin Jun 15 '12 at 15:53
-
I didn't say it was a TR, I said it introduced the TR3 material, which it did. The document published in 2003 was the 1998 standard plus the CA. It was not a new C++ standard and the 1998 standard was not amended in any way. – Michael J Jun 15 '12 at 16:03
-
@MichaelJ: There's never even *been* a TR3. There have (strangely enough) been two separate documents, both called "TR1". There's a good chance that there will fairly soon be a TR2 (they were collecting material for it, but stopped temporarily to concentrate on finishing the standard). The first sentence in my previous comment is a direct copy-n-paste quote from the committee's web page (as you'd know if you'd bothered to click on it and read). – Jerry Coffin Jun 15 '12 at 16:17
-
Now, if somebody has to choose between the ISO C++ standard committee saying "ISO 14882:2003 is a standard" and @MichaelJ saying "there is no 2003 standard for C++", who do you think *any* reasonable person should believe? – Jerry Coffin Jun 15 '12 at 16:22
-
Re: TR3 -- You are correct. I meant TR1. I don't know where my brain was. – Michael J Jun 16 '12 at 05:32
-
But C++03 doesn't incorporate any of either TR1 either. What's been incorporated is into C++11. – Jerry Coffin Jun 16 '12 at 05:34
-
"ISO 14882:2003 is a standard" is, of course, correct. "ISO 14882:2003 is a standard defining the C++ language" is false and has not (to my knowledge) been alleged by ISO. _cplusplus == 199711L means that the compiler implements the C98 standard. There is no _cplusplus == 2003xx because there was not a new version of the C++ language in 2003. There was a CA, standardising some new features which were quarantined by putting them in the TR1 namespace. In C++11, the c98 language spec was altered and the TR1 material moved into the language proper. – Michael J Jun 16 '12 at 05:39
-
1If ISO 14882:2003 doesn't define C++, what do you think it does define? The title page says: "INTERNATIONAL STANDARD ISO/IEC 14882 Second edition 2003-10-15 Programming languages — C++ Langages de programmation — C++" – Jerry Coffin Jun 16 '12 at 05:44
-
I think we have both expressed our opinions adequately. Unless there is anything new, I probably won't respond any further. Thanks for the discussion. – Michael J Jun 16 '12 at 05:44
-
-
-
I think SD-6 the macros document should define __cpp1998, __cpp2011, ... I know I've flubbed the months. Also, we're looking at potentially three products in this decade (20xx). They could even be nice and #define __cpp2003 __cpp1998. – emsr Oct 05 '17 at 20:31
-
@emsr If like everyone you can't remember the month at which the standard was published, you can do a dirty "#if __cplusplus >= 202000L", i.e. with 00 in place of the month. Of even __cplusplus / 100. (didn't work for C++98 which was published in 1997). – Johan Boulé Dec 13 '20 at 23:03
-
-
cfront wasn't really a compiler. Or C++. It was a translator of early language version to C code – Swift - Friday Pie Jul 31 '23 at 15:17
-
1@Swift-FridayPie: I guess you're free to hold whatever opinion you choose, regardless of how foolish it may look to some of us who have the "disadvantage" of things like having used cfront, and written code in the language you claim wasn't C++. – Jerry Coffin Jul 31 '23 at 19:53
-
@JerryCoffin Then I have a "disadvantage" of remebering Algol and original K&R C... It's not a question of seniority, the language Cfront used was by implementation and behaviour much different from modern C or C++. Cfornt is the actual source of bad press C++ receives because the dismissive stamp "C with classes" refuses to go away from people's mind 40 years later. "C++ is just a superset of C" is another legacy of that. "Templates are macroses" ideom wreaked havoc in whirlwind of UBs in big projects as I witnessed it. – Swift - Friday Pie Jul 31 '23 at 20:49
-
From standpoint of CS cfront was a neat effort. But it was nitpicked to half-death by some reputable giants. – Swift - Friday Pie Jul 31 '23 at 20:54
-
@Swift-FridayPie: Well, I was trying to be nice about it, but okay: people who know what a compiler is, recognize that cfront was a compiler. And people who know what C++ is, recognize that although it's not *current*, the language that it accepted most certainly was C++. Now, if you want to claim that early C++ was open to a lot of improvement, you'll get no argument from me. For that matter, I'd agree that current C++ is open to improvement, and what we're using now will someday be obsolete. But it'll be C++ nonetheless. – Jerry Coffin Aug 01 '23 at 04:11
I think preprocessor defines for the various versions should go into SD-6:
#define __cpp_1997 199711L
#define __cpp_2003 __cpp_1997
#define __cpp_2011 201103L
#define __cpp_2014 201402L
#define __cpp_2017 201703L
Looking into the 2020s we might have three more standards. I don't doubt that many implementors will have code supporting standards from 1997 onwards.
I for one would like a mnemonic define so I won't have to keep coming back to this post.

- 15,539
- 6
- 49
- 62
-
Use `#if __cplusplus >` whatever you want. Please do not copy [the bad practice from MS](https://developercommunity.visualstudio.com/content/problem/540773/getversion-getversionex-deprecated-but-shouldnt-be.html), despite [some mysteriously historical issues](https://devblogs.microsoft.com/oldnewthing/20190627-00/?p=102626). – FrankHB Aug 14 '20 at 05:50
-
2What's SD-6? FrankHB is right. And it's also highly confusing. People might start doing "#ifdef __cpp_2017" thinking it will mean something. If you want a dirty check without remembering the months, then the preprocessor can do it, either by comparing >= or < with a number literal where you typed 00 in place of the month, or you can also divide by 100 so you get only the year. – Johan Boulé Dec 13 '20 at 23:46
__cplusplus value for C++20
According to Acorn's answer __cplusplus is macro defined as 202002 based on the link cpp.predefined(1.1)! This definition is also to be found at this cppreference! Search for __cplusplus
This has since been updated to 202004
To know its actual value for Microsoft Visual C++ in Visual Studio community 2019 do the following:
- Create a Visual C++ project
- Right mouse click on the Solution.
- On the dropdown menu click on Properties at the bottom
- A pop up dialog opens up
- Click on "Configuration Properties" to expand it
- Click on "C/C++" to expand it.
- Click on "All Options".
- You should find "Additional Options" on the right
- On the adjacent right column of this paste: /std:c++latest /Zc:__cplusplus
- You should find "Additional Options" on the right
- Click on "All Options".
- Click on "C/C++" to expand it.
Click "Apply" button and then the "OK" button
In function main() run the following code to get the value of __cplusplus
int main()
{
long cppVer = __cplusplus;
std::cout << "__cplusplus value for C++20 is: ";
std::cout << std::to_string( cppVer ) << std::endl;
}
The code should display the following:
__cplusplus value for C++20 is: 202004

- 47
- 1
- 1
-
Thanks for your contribution ! There where two questions but you didn't answer to this one : what does it signify? – Jun 23 '21 at 09:43
That means it is compatible with the 1997 C++ standard (actually known as C++ '98 as they took too long to ratify it..

- 7,631
- 2
- 24
- 30