c语言container_of 编译报错
求指针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 编译报错的更多相关文章
- 使用C#模拟Outlook发送邮件,代码编译报错
添加OutLook API using OutLook = Microsoft.Office.Interop.Outlook; 发送邮件方法 public void SendEmail() { Out ...
- cordova编译报错:Execution failed for task ':processDebugResources'
cordova编译报错:Execution failed for task ':processDebugResources' 引发这个错误的最扩祸首就是一个中文命名的文件,不知道什么时候加入的,我写了 ...
- 编译报错dereferencing pointer to incomplete type
关于编译报错“dereferencing pointer to incomplete type... 多是没找到结构体的定义,可以在本地复制其定义试试. 参考: http://my.oschina.n ...
- 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] -------------------------- ...
- [Intellij] 编译报错 javacTask
报错信息: Idea 编译报错 javacTask: 源发行版 1.6 需要目标发行版 1.6 解决方案:
- jenkis编译报错:需要class,interface或enum
现象: 1.jenkis编译报错:需要class,interface或enum 2.使用ant进行编译ok. 解决方法: 1. Jenkis重新编译一个以前成功的svn版本,直至编译成功. 2.Jen ...
- 对arm指令集的疑惑,静态库运行,编译报错等问题
转载自http://www.jianshu.com/p/4a70aa03a4ea?utm_campaign=hugo&utm_medium=reader_share&utm_conte ...
- xocde7下导入libsqlite3.tbd编译报错的解决办法
在xocde7下没有libsqlite3.dylib,只有libsqlite3.tbd,然后我导入了tbd.编译报错error: /Applications/Xcode.app/Contents/De ...
- 关于vue-clidown到本地后,拷贝文件库到另外一台电脑上npm run dev编译报错的处理
这些天自己在用vue-cli项目,在家里的电脑下下来后写了一些demo,拿到公司继续开发的时候发现删除node_modules文件,运行npm install和npm run 百度,搜狗了好久都没有找 ...
- openldap 编译报错MozNSS not found
openldap 编译报错 1)报错 MozNSS not found - please specify the location to the NSPR and NSS header files i ...
随机推荐
- OpenMP Sections Construct 实现原理以及源码分析
OpenMP Sections Construct 实现原理以及源码分析 前言 在本篇文章当中主要给大家介绍 OpenMP 当中主要给大家介绍 OpenMP 当中 sections construct ...
- java2022.7.9
知识点
- shell:判断某个变量是否包含字符串/变量的方法
尝试了有3种方法: 1.使用"=~"符号,注意前后必须要有空格! ** 可以输出正确结果,被匹配的字符串必须要有引号括起来!** [clouder@ana53 bin]$ a1=' ...
- sql 查找连续的时间区间以及连续天数
create table tmptable(rq datetime) go insert tmptable values('2010.1.1') insert tmptable values('201 ...
- Python实战项目5-Git远程仓库/分支合并/冲突解决
Git分支 为什么要有分支 可以保证主分支的版本都是可以查看的版本 我们都在开发分支开发,开发完成 合并代码 分支操作 分支查看 git branch 分支创建 git branch 分支名 分支切换 ...
- 如何免费获取高清动图并将其插入到Markdown中
一.发现问题 我在做excel笔记的时候,想要动态展示操作excel的过程,由于我平时的笔记都是使用markdown记录,所以要在md文件中插入动图. 二.解决问题 细化问题 1.如何将动图插入到md ...
- 论文学习 Dilated Inception U-Net (DIU-Net) for Brain Tumor Segmentation 1
好记性不如烂笔头 边学习边记录1 主题:脑肿瘤分割 使用基于Unet的端到端的网络结构,在扩张和紧缩路径中加入了Inception模块和空洞卷积. 数据集:Tumor Segmentation (Br ...
- MS-TCT: Multi-Scale Temporal ConvTransformer for Action Detection概述
1.针对的问题 为了在未修剪视频中建模时间关系,以前的多种方法使用一维时间卷积.然而,受核大小的限制,基于卷积的方法只能直接获取视频的局部信息,不能学习视频中时间距离较远的片段之间的直接关系.因此,这 ...
- eclipse调整控制台长度
- SQLServer错误:expected a simple type, a tuple or a list
dict_data = { 'request_id': request_id, 'original_id': request_body.original_id, 'unit_type': reques ...