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.)
The correct option is -std=c11 .
GCC provides experimental support for the 2011 ISO C++ standard. This support can be enabled with the -std=c++11 or -std=gnu++11 compiler options; the former disables GNU extensions. As of GCC 4.8.
H2CO3 is right, you can use a makefile with the CXXFLAGS set with -std=c++11 A makefile is a simple text file with instructions about how to compile your program. Create a new file named Makefile (with a capital M). To automatically compile your code just type the make command in a terminal.
You can use command-line flag -std to explicitly specify the C++ standard. For example, -std=c++98 , or -std=gnu++98 (C++98 with GNU extensions) -std=c++11 , or -std=gnu++11 (C++11 with GNU extensions)
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
.
Just to let you know GCC 4.9.x has far more complete support than older versions. If you really need to use this feature, please switch to anything 4.8+ Here is the support status -- https://gcc.gnu.org/wiki/C11Status
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With