How to enable c11 on later versions of gcc?

Paul Baltescu picture Paul Baltescu · Apr 27, 2013 · Viewed 80.2k times · Source

I currently use gcc 4.6.3. My understanding is that gcc by default uses the gnu89 standard and I would like to enable C11, the latest C standard. I tried:

[pauldb@pauldb-laptop test ]$ gcc -std=c11 -o test test.c
cc1: error: unrecognised command line option ‘-std=c11’

I replaced c11 with gnu11 and I get the same error. What is the correct way to enable the latest C standard for gcc?

(Note: I'm interested in the latest C standard and not the latest C++ one.)

Answer

ouah picture ouah · Apr 27, 2013

The correct option is -std=c11.

However, it is not available in gcc 4.6. You need at least gcc 4.7 to have this option supported. In some older versions like gcc 4.6, the option -std=c1x was available with experimental (i.e., very limited) support of C11.

Note that the current version of gcc is gcc 8.2.