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 ...
随机推荐
- 面向对象程序设计(三):C++模板operator Type类型转换
学习算法的时候遇到了一个不认识的写法,去网上查了查,看到有一篇写的挺好的,转载过来了 C++隐式类型转换运算符operator type()用法详解 对象向基本数据类型转换: 点击查看代码 #incl ...
- 2211-14MongoDB学习
学习资源来自菜鸟教程 MongoDB数据库 MongoDB概念解析 不管我们学习什么数据库都应该学习其中的基础概念,在mongodb中基本的概念是文档.集合.数据库,下面我们挨个介绍. 下表将帮助您更 ...
- 毕设进度更新(真的不知道自己做到哪- - 备忘录性质)+3.19是mavan配置的常见问题
3.19 maven的配置 我也不知道我的cmd 输入mvn complie就是报错 也没办法下载 奇了怪了 检查了setting文件也没得- - 然后也没办法像老师一样直接导入tomcat的包 但是 ...
- Navicat修改mysql表的字符集和排序规则
突然想起前一阵子,在做javaweb后端debug的时候遇到的这个问题.由于在Dao层测试的时候没有尝试过中文的测试例,所以在Service写好后一直不报错但是无法插入数据库. 找了好久才发现是Mys ...
- 安卓逆向 ARM基础篇
1.ARM 与 Andorid 的关系 android 的操作系统是 LINUX 内核 LINux又是ARM 2.ARM汇编规范 3.ARM指令格式 ARM常用指令开始 1.ARM 的跳转指令 PC ...
- 代码随想录算法训练营day21 | leetcode ● 530.二叉搜索树的最小绝对差 ● 501.二叉搜索树中的众数 ● ***236. 二叉树的最近公共祖先
LeetCode 530.二叉搜索树的最小绝对差 分析1.0 二叉搜索树,中序遍历形成一个升序数组,节点差最小值一定在中序遍历两个相邻节点产生 ✡✡✡ 即 双指针思想在树遍历中的应用 class So ...
- vue 获取select选中的当前option所在对象的各种值
- 化学式latex语法
$2 CO_2 \stackrel{光}{\underset{\text{催化剂}}{\longrightarrow}}2 Fe + 3 CO_2$ $\ce{CO2}$ $\ce{CU2+}$ $\ ...
- Ansible介绍以及基于角色搭建LNMP和zabbix
1 ansible 常用指令总结,并附有相关示例. /usr/bin/ansible 主程序,临时命令执行工具 /usr/bin/ansible-doc 查看配置文档,模块功能查看工具,相当于man ...
- LeetCode-2044 统计按位或能得到最大值子集的数目
来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/count-number-of-maximum-bitwise-or-subsets 题目描述 给 ...