c - #定义错误: expected declaration specifiers or '...' before '(' token

标签 c compiler-errors c-preprocessor

你知道为什么我会从这段代码中得到这些错误吗?

#define container_of(ptr, type, member) ({\
    const typeof( ((type *)0)->member ) *__mptr = (ptr);\
    (type *)( (void *) ( (char *)__mptr - offsetof(type,member) ) );})

error: expected declaration specifiers or '...' before '(' token
error: '__mptr' undeclared (first use in this function)

最佳答案

感谢您的帮助!

用两侧各有两个下划线的 typeof 替换 'typeof' 解决了问题。

关于c - #定义错误: expected declaration specifiers or '...' before '(' token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27029643/

相关文章:

c - 指针问题

c++ - 我们如何将一个 100 GB 的文件拆分成一百个 1 GB 的文件?

关于大小的字符数组与字符指针

c++ - 当我在Visual Studio中编译C++项目时,为什么会发生 fatal error “LNK1104: cannot open file ' cryptlib.lib?

c - 在 C 中的 scanf 中使用定义(类型说明符)

c - 矩阵中元素邻居的最小值

c++ - 对类型值的引用绑定(bind)删除限定符 MULTISET

c++ - "Missing vtable"为析构函数,但析构函数已定义

c - GCC __func__ 被评估为空字符串

c - 重用/递增 C 宏定义?