求指针ptr所在的结构体实例的首地址,

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

编译报错

 1 src/utils/dds_rbtree.c: In function ‘rbtree_get_prev’:
2 src/utils/rbtree.h:54:11: error: unknown type name ‘typeof’
3 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
4 ^
5 src/utils/rbtree.h:76:37: note: in expansion of macro ‘container_of’
6 #define rb_entry(ptr, type, member) container_of(ptr, type, member)
7 ^~~~~~~~~~~~
8 src/utils/dds_rbtree.c:377:5: note: in expansion of macro ‘rb_entry’
9 rb_entry(pTargetBaseNode, RB_DATA_NODE_T, stRbBaseNode);
10 ^~~~~~~~
11 src/utils/rbtree.h:54:28: error: expected ‘)’ before numeric constant
12 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
13 ^
14 src/utils/rbtree.h:76:37: note: in expansion of macro ‘container_of’
15 #define rb_entry(ptr, type, member) container_of(ptr, type, member)
16 ^~~~~~~~~~~~
17 src/utils/dds_rbtree.c:377:5: note: in expansion of macro ‘rb_entry’
18 rb_entry(pTargetBaseNode, RB_DATA_NODE_T, stRbBaseNode);
19 ^~~~~~~~
20 src/utils/rbtree.h:54:30: error: expected ‘)’ before ‘->’ token
21 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
22 ^
23 src/utils/rbtree.h:76:37: note: in expansion of macro ‘container_of’
24 #define rb_entry(ptr, type, member) container_of(ptr, type, member)
25 ^~~~~~~~~~~~
26 src/utils/dds_rbtree.c:377:5: note: in expansion of macro ‘rb_entry’
27 rb_entry(pTargetBaseNode, RB_DATA_NODE_T, stRbBaseNode);
28 ^~~~~~~~
29 src/utils/rbtree.h:54:41: error: expected ‘)’ before ‘*’ token
30 const typeof( ((type *)0)->member ) *__mptr = (ptr); \

原因为编译是添加了c99选项,typeof为gcc扩展功能,取变量的类型,c99不支持,识别为函数,删去--std=c99

LD_C_FLAGS   += -ldl -lm -lpthread -lrt --std=c99

typeof用法:https://blog.csdn.net/rosetta/article/details/90741468

c99 c11 差异:https://blog.csdn.net/u010217055/article/details/128957497

C++情况下参考

参考:https://blog.csdn.net/linuxsmallping/article/details/83418546

c语言container_of 编译报错的更多相关文章

  1. 使用C#模拟Outlook发送邮件,代码编译报错

    添加OutLook API using OutLook = Microsoft.Office.Interop.Outlook; 发送邮件方法 public void SendEmail() { Out ...

  2. cordova编译报错:Execution failed for task ':processDebugResources'

    cordova编译报错:Execution failed for task ':processDebugResources' 引发这个错误的最扩祸首就是一个中文命名的文件,不知道什么时候加入的,我写了 ...

  3. 编译报错dereferencing pointer to incomplete type

    关于编译报错“dereferencing pointer to incomplete type... 多是没找到结构体的定义,可以在本地复制其定义试试. 参考: http://my.oschina.n ...

  4. Maven-010-maven 编译报错:Failure to ... in ... was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced.

    今晚在编译 maven 项目的时候,命令行报错,出现 Failure to ... in ... 类似错误,详细的错误信息如下所示: [INFO] -------------------------- ...

  5. [Intellij] 编译报错 javacTask

    报错信息: Idea 编译报错 javacTask: 源发行版 1.6 需要目标发行版 1.6 解决方案:

  6. jenkis编译报错:需要class,interface或enum

    现象: 1.jenkis编译报错:需要class,interface或enum 2.使用ant进行编译ok. 解决方法: 1. Jenkis重新编译一个以前成功的svn版本,直至编译成功. 2.Jen ...

  7. 对arm指令集的疑惑,静态库运行,编译报错等问题

    转载自http://www.jianshu.com/p/4a70aa03a4ea?utm_campaign=hugo&utm_medium=reader_share&utm_conte ...

  8. xocde7下导入libsqlite3.tbd编译报错的解决办法

    在xocde7下没有libsqlite3.dylib,只有libsqlite3.tbd,然后我导入了tbd.编译报错error: /Applications/Xcode.app/Contents/De ...

  9. 关于vue-clidown到本地后,拷贝文件库到另外一台电脑上npm run dev编译报错的处理

    这些天自己在用vue-cli项目,在家里的电脑下下来后写了一些demo,拿到公司继续开发的时候发现删除node_modules文件,运行npm install和npm run 百度,搜狗了好久都没有找 ...

  10. openldap 编译报错MozNSS not found

    openldap 编译报错 1)报错 MozNSS not found - please specify the location to the NSPR and NSS header files i ...

随机推荐

  1. springboot多模块controller访问的问题

    参考 https://blog.csdn.net/qq_25091649/article/details/88429512 情况一:在主类直接写controller接口,能够访问到 @SpringBo ...

  2. Vue的介绍

    目录 Vue介绍 一.前端发展史 二.Vue介绍 1.Vue是什么? 2.M-V-VM 架构思想 3.组件化开发.单页面应用 4.版本问题 三.第一个helloworld 1.了解开发前端的编辑器 2 ...

  3. c++标准库string的使用完美总结——十分详细,复习学习记忆都可以使用

    std::string详解 之所以抛弃char*的字符串而选用C++标准程序库中的string类,是因为他和前者比较起来,不必 担心内存是否足够.字符串长度等等,而且作为一个类出现,他集成的操作函数足 ...

  4. P22_条件渲染

    条件渲染 wx:if 在小程序中,使用 wx:if="{{condition}}" 来判断是否需要渲染该代码块: 也可以用 wx:elif 和 wx:else 来添加 else 判 ...

  5. Seata分布式事务

    使用Seata版本:1.6.1(2023/2/6最新版)该版本存在很多坑,相较于1.0版本,配置上存在很多差别,如果你的版本不同,请不要参考本文. 1.6.1配置存在许多问题,比较难找,如果你使用1. ...

  6. UBUNTU18.04安装Pangolin

    https://github.com/stevenlovegrove/Pangolin

  7. ajax的原理是什么?如何实现?

    一.是什么 AJAX全称(Async Javascript and XML) 即异步的JavaScript 和XML,是一种创建交互式网页应用的网页开发技术,可以在不重新加载整个网页的情况下,与服务器 ...

  8. C语言-补漏 -内存管理

    8. 全局就是简简单单编写的 静态函数--只能在当前文件内使用的函数

  9. 抗TNF治疗改变JIA患者PBMC基因表达谱,可预测疗效

    抗TNF治疗改变JIA患者PBMC基因表达谱,可预测疗效 Moorthy LN, et al. ACR 2007. Presentation No:1713. 背景:我们假设儿童期发生的特发性关节炎( ...

  10. EMBARK研究: 依那西普治疗早期nr-axSpA达48周的临床和MRI疗效

    关键词: 放射学阴性中轴型SpA; TNF拮抗剂; 磁共振影像 EMBARK研究48周结果: 依那西普治疗早期放射学阴性中轴型SpA患者的临床与MRI疗效 电邮发布日期:2016年1月25日 文献: ...