Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the __STDC_VERSION__ value for C11?

Tags:

c

macros

iso

c11

I know that compilers use __STDC__ to indicate that a compiler is standard C and, from, there, you can use __STDC_VERSION__ to figure out which level of the standard you're using.

I also know that C90 had no value, C90 amendment 1 had 199401L and C99 had 199901L.

The latest C1x draft I have simply states it as 201ymmL and I'm assuming it was made a less "vague" value in the final standard.

My guess is that it will be 201112L since that's when C11 was ratified but I'd like to be certain.

I thought I could try using gcc -std=c1x but the version of gcc I'm running doesn't support that yet.

Does anyone know what the actual value is?

like image 457
paxdiablo Avatar asked Feb 15 '12 13:02

paxdiablo


People also ask

What is C11 in C language?

C11 is the informal name for ISO/IEC 9899:2011, the current standard for the C language that was ratified by ISO in December 2011. C11 standardizes many features that have already been available in common contemporary implementations, and defines a memory model that better suits multithreading.

Should I use C99 or C11?

It is best to use C11 as that is the current standard. C99 and C11 both contained various "language bug fixes" and introduced new, useful features.

Does GCC support C11?

GCC has substantially complete support for this standard, enabled with -std=c11 or -std=iso9899:2011 .

What is the latest C standard?

C17 is the informal name for ISO/IEC 9899:2018, the most recent standard for the C programming language, prepared in 2017 and published in June 2018. It replaced C11 (standard ISO/IEC 9899:2011). C17 will be superseded by C2x.


2 Answers

With -std=c11 in gcc, 201112L is used for __STDC_VERSION__

See this gcc patch on December 20, 2011 on gcc ml:

https://www.mail-archive.com/[email protected]/msg23572.html

And note that apparently the ISO version of C11 forgot to update the 201ymmL from the Draft.

The intended final __STDC_VERSION__ value, 201112L, is also implemented (the editor forgot to update the 201ymmL placeholders before sending the document for publication by ISO).

See also DR #411, which makes it official that the intended value is 201112l. The editor has said that "The committee is trying to get it approved as a TC as soon as possible.". (TC = "Technical Corrigendum")

EDIT (July 16, 2012): Technical Corrigendum 1 (ISO/IEC 9899:2011/Cor 1:2012) released on July 15, 2012 fixes the __STDC_VERSION__ to 201112L.

like image 117
ouah Avatar answered Sep 21 '22 08:09

ouah


According to this post to the GCC mailing list, the final value is, as you suspected, 201112L.

like image 26
Dan Moulding Avatar answered Sep 18 '22 08:09

Dan Moulding