gcc验证c99支持

编译程序的时候需要加上-std=c9 才可以。
以下程序是验证gcc是否支持c99标准的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@wds029 ~]# cat c99test.c 
#include <stdio.h>

int main(void)
{
#ifdef __STDC__
printf("%s\n", "stardard C");
#endif
#ifdef __STDC_VERSION__
printf("%ld\n", __STDC_VERSION__);
#endif
return 0;
}
[root@wds029 ~]#

查看当前gcc版本

1
2
3
4
5
6
7
[root@wds029 ~]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@wds029 ~]#

验证

1
2
3
4
5
[root@wds029 ~]# gcc -std=c99 -o c99_test c99test.c
[root@wds029 ~]# ./c99_test
stardard C
199901
[root@wds029 ~]#

课程中心

在线课程