- 論壇徽章:
- 0
|
最近騷,想試試c11, 我是centos6.3 gcc原先好像是4.4.7,我升級(jí)到4.8.1了。
編譯總出現(xiàn)問(wèn)題。在網(wǎng)上轉(zhuǎn)了一大圈,沒(méi)有找到解決方法。 各位有碰到過(guò)的嗎?還是我的路子就走錯(cuò)了?????
編譯 gcc -std=c11 b.c
報(bào)錯(cuò)如下:- 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);
- ^
復(fù)制代碼- #include <stdio.h>
- 代碼是這個(gè)
- #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;
- }
復(fù)制代碼 |
|