我一直在尋找這個時間過長,看不出是什麼問題:混淆gcc的錯誤信息
#include <stdio.h>
typedef struct {
int a;
int b;
} S;
#define F(a,b) (v.a = a, v.b = b, v)
int main(void) {
S s, v;
s = (v.a = 1, v.b = 2, v); // this works as expected
printf("s = { %d %d } \n", s.a, s.b);
s = F(1, 2); // but gcc complains about the macro equivalent
printf("s = { %d %d } \n", s.a, s.b);
return 0;
}
GCC抱怨:
In function 'main':
Line 17: error: expected identifier before numeric constant
兩個預處理後的作業應該是相同的,但顯然我錯過了一些東西...
您可以在此運行代碼:http://codepad.org/0c1aUBLm
D'哦 - 我知道它是什麼簡單而明顯的,但我無法看到它 - 感謝... –
@PaulR我假設你很累了:)得到一些咖啡/睡覺:) – 2013-04-14 21:38:09
你現在正在 - 腦功能嚴重枯竭剛纔。 ;) –