求指针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. 后台管理系统带关闭的选项卡(多标签页)功能 适配bootstrap3和4 Bootstrap Hover Dropdown

    眼看着是不是很熟悉,其实基本大部门后台管理系统都有这个功能,使用iframe实现展示标签页面. 主要功能:标签页点击,添加标签页,向左滚动标签页,向右滚动标签页,刷新当前标签页,关闭当前标签页,关闭其 ...

  2. Syntax Error: Error: Cannot find module ‘node-sass‘

    出现问题原因: vscode运行前端项目输入npm run dev命令触发此错误 解决办法: 指定淘宝镜像安装node-sass win+r 打开cmd控制台输入 npm install -g cnp ...

  3. ubuntu18.04编译webrtc_android库

    webrtc 是谷歌提供的音视频通讯方案, 能够很好的解决音视频互联互通的场景. 本文基于 Ubuntu 18.04 编译 android 版本的过程, 其它平台也可以参考, 基本都大同小异. 编译环 ...

  4. 很奇怪CSDN的审核

    https://www.cnblogs.com/lup9304/p/15310753.html https://www.cnblogs.com/lup9304/p/15328809.html 很奇怪C ...

  5. odoo 给列表视图添加按钮实现数据文件导入

    实践环境 Odoo 14.0-20221212 (Community Edition) 代码实现 模块文件组织结构 说明:为了更好的表达本文主题,一些和主题无关的文件.代码已略去 odoo14\cus ...

  6. [代码审计基础 02]-SQL注入和预编译和预编译绕过

    SQL注入 thinkphp基本没得SQL注入,除非魔改 ORM框架的错误使用 一个专门用来防御SQL注入的框架 错误写法-java/mybatis <select id = "fin ...

  7. jsHtml解码

    //将HTML代码转换为文本 function HTMLDecode(text) { var temp = document.createElement("div"); temp. ...

  8. LeetCode-593 有效的正方形

    来源:力扣(LeetCode)链接:https://leetcode.cn/problems/valid-square 题目描述 给定2D空间中四个点的坐标 p1, p2, p3 和 p4,如果这四个 ...

  9. Spring Boot如何自定义监控指标

    1.创建项目 pom.xml引入相关依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=" ...

  10. ansible 离线部署

    1.安装 python 环境 wget https://mirrors.bfsu.edu.cn/anaconda/archive/Anaconda3-2022.10-Linux-x86_64.sh s ...