[英]How to enable c11 on later versions of gcc?
I currently use gcc 4.6.3
. 我目前使用的是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. 我的理解是gcc
默认使用gnu89
标准,我想启用最新的C标准C11。 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. 我用gnu11
替换了c11
,我得到了同样的错误。 What is the correct way to enable the latest C standard for gcc? 为gcc启用最新C标准的正确方法是什么?
(Note: I'm interested in the latest C standard and not the latest C++ one.) (注意:我对最新的C标准感兴趣,而不是最新的C ++标准。)
The correct option is -std=c11
. 正确的选项是-std=c11
。
However, it is not available in gcc 4.6
. 但是,它不适用于gcc 4.6
。 You need at least gcc 4.7
to have this option supported. 您至少需要gcc 4.7
来支持此选项。 In some older versions like gcc 4.6
, the option -std=c1x
was available with experimental (ie, very limited) support of C11. 在某些旧版本(如gcc 4.6
,选项-std=c1x
可用于C11的实验(即非常有限)支持。
Note that the current version of gcc
is gcc 8.2
. 请注意,当前版本的gcc
是gcc 8.2
。
Just to let you know GCC 4.9.x has far more complete support than older versions. 只是为了让你知道GCC 4.9.x比旧版本提供更完整的支持。 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 如果你真的需要使用这个功能,请切换到4.8+这里是支持状态 - https://gcc.gnu.org/wiki/C11Status
gcc 5.2.0使用命令行选项'-std = c11'
Inside a .spec file : 在.spec文件中:
%define gcc_ver %(if [[ $(gcc -dumpversion) > 4.7 ]]; then echo 1; else echo 0; fi)
# Do we use c11 ?
%if 0%{?gcc_ver} < 1
%global std_c11 0
%else
%global std_c11 1
%endif
# if the configure of the package supports it add :
%if %{std_c11}
--enable-cxx11 \
%endif
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.