发布时间:2017-04-22 09:09:00 作者:佚名 阅读:(1176)
#include <stdio.h> int main() { #define offsetof(type, member) ((size_t) &((type *)0->member)) struct test { int a; int b; }; printf("offset of a %d\n", offsetof(struct test, a)); printf("offset of b %d\n", offsetof(struct test, b)); return 0; }
test.c:5:57: 错误:‘->’参数类型无效(有‘int’)
#define offsetof(type, member) ((size_t) &((type *)0->member))
^
test.c:13:32: 附注:in expansion of macro ‘offsetof’
printf("offset of a %d\n", offsetof(struct test, a));
^~~~~~~~
test.c:5:57: 错误:‘->’参数类型无效(有‘int’)
#define offsetof(type, member) ((size_t) &((type *)0->member))
^
test.c:14:32: 附注:in expansion of macro ‘offsetof’
printf("offset of b %d\n", offsetof(struct test, b));
^~~~~~~~
#include <stdio.h> int main() { #define offsetof(type, member) ((size_t) &(((type *)0)->member)) struct test { int a; int b; }; printf("offset of a %d\n", offsetof(struct test, a)); printf("offset of b %d\n", offsetof(struct test, b)); return 0; }
欢迎分享转载→ C语言编译错误:错误:‘->’参数类型无效(有‘int’)
© 2015-2021 - 吾爱编程网 版权所有 苏ICP备18033726号-1关于我们 - 网站声明 - 联系我们