我一直在寻找这个时间过长,看不出是什么问题:混淆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
你现在正在 - 脑功能严重枯竭刚才。 ;) –