I know that for C11, I can test #if(__STDC_VERSION >= 20112L)
. But for -std=c1x
what macro and/or value should I test it?
what's the nomenclature of this standard? or maybe a informal name, if any. I hope this is clear. Thanks in advance.
gcc's -std=c1x
option is synonymous with -std=c11
, and it sets __STDC_VERSION__
to the same value, 201112L
(note: not 20112L
).
Before it was released, the new C standard was referred to as "C1X" (since it wasn't known exactly when it would come out), and gcc added a -std=c1x
option to enable partial support for the upcoming standard. When the standard was released as C11, gcc added -std=c11
to enable (still partial) support, but has kept the -std=c1x
option for compatibility.
(Due to an editing error, the released 2011 ISO C standard doesn't specify the value of __STDC_VERSION__
, but the editor has stated that 201112L
is correct; see this question.)
Jens Gustedt's comment makes a good point. gcc -std=c11
sets __STDC_VERSION__
to 201112LL
, which is supposed to imply C11 conformance, but in fact it's still missing a log of C11 features. We can expect this to improve in future releases.
Similarly, -std=c99
sets __STDC_VERSION__
to 199901L
, but it doesn't quite conform to the C99 standard (the current status is documented here. gcc's C90 conformance (with -ansi
or -std=c90
) conforms quite well to the C90 standard.