求指针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. Zstack迁移实战记录1

    https://blog.csdn.net/weixin_43767046/article/details/113748775 这段时间除了那个重度烤机测试(上面链接),还在做另一件事,想再做一个服务 ...

  2. string str = string.Empty也会出错?

    如题 为什么会出现这种情况?大佬解释一下.

  3. SVN提交到服务器退回至指定版本(撤销操作)

    一.撤销已提交内容如果不小心把修改错误的文件提交到服务器上去了 可对其进行复原(指定单个文件撤销) 解决方法: 查看修改的日志 查看错误提交的文件 可以查看到这个文件改了什么 复原此版本作出的修改 然 ...

  4. crypto-gmsm国密算法库

    crypto-gmsm国密算法库 一.开发背景 crypto-gmsm国密算法库是国密商密算法(SM2,SM3,SM4)工具类封装,国产密码算法(国密算法)是指国家密码局认定的国产商用密码算法,目前主 ...

  5. python sys.argv(全局文本索引替换)

    #利用sys.argv(实现从程序外部向程序传递参数.)写一个脚本.#全局替换(old_str to new_str,filename)import sys #导入sys模块print(sys.arg ...

  6. Nginx 同一个域名自动识别 pc h5

    首先设置环境变量 我们先设置变量,通过判断来改变变量的值(注: 我写在server中) set $is_mobile false; # 初始值 if ( $http_cookie ~* "A ...

  7. 测开-面试题-MySQL

    1 增删改查的关键字分别是什么? 答: insert into \ replace into.delete.update.select 2 内连接和外连接的区别? 答: (1)内连接,只会展示与两表关 ...

  8. python数据方面的文章

    excel 对接 jupyter      https://mp.weixin.qq.com/s/NTCIOs_Yz3MIRgT8S36yGQ pandas 常用分拆数据         https: ...

  9. MySQL-存储引擎-索引

    事务 方式1:set @@autocommit = 0 -- 将事务提交方式设置为手动 方式2:start transaction -- 开启事务 事务四大特性ACID: A:原子性(Atomicit ...

  10. 浏览器tab标签切换触发监听事件visibilitychange

    document.addEventListener('visibilitychange', function() { if(document.hidden){ //当页面切换或隐藏时触发的代码,可以用 ...