- 论坛徽章:
- 0
|
最近骚,想试试c11, 我是centos6.3 gcc原先好像是4.4.7,我升级到4.8.1了。
编译总出现问题。在网上转了一大圈,没有找到解决方法。 各位有碰到过的吗?还是我的路子就走错了?????
编译 gcc -std=c11 b.c
报错如下:- b.c: In function ‘main’:
- b.c:22:5: warning: implicit declaration of function ‘_Generic’ [-Wimplicit-function-declaration]
- put (123);
- ^
- b.c:4:30: error: expected expression before ‘float’
- #define put(x) _Generic((x), float: put_float, int: put_int)(x)
- ^
- b.c:22:5: note: in expansion of macro ‘put’
- put (123);
- ^
- b.c:4:30: error: expected expression before ‘float’
- #define put(x) _Generic((x), float: put_float, int: put_int)(x)
- ^
- b.c:23:5: note: in expansion of macro ‘put’
- put (1.2f);
- ^
复制代码- #include <stdio.h>
- 代码是这个
- #define put(x) _Generic((x), float: put_float, int: put_int)(x)
- void put_float (float x)
- {
- printf ("%f\n", x);
- }
- void put_int (int x)
- {
- printf ("%d\n", x);
- }
- int
- main (void)
- {
- //put_int (123);
- //put_float (1.2f);
- put (123);
- put (1.2f);
- return 0;
- }
复制代码 |
|