看开源代码时,看到这个字段,有点理解不了

睡在床板下_ 2008-05-11 09:33:47
在看vlc代码时,结构体中碰到这个字段:

struct vlc_object_t
{
VLC_COMMON_MEMBERS
};

#define VLC_COMMON_MEMBERS \
/** \name VLC_COMMON_MEMBERS \
* these members are common for all vlc objects \
*/ \
/**@{*/ \
\
............................ \
/* Private data */ \
void * p_private; \
\
/** Just a reminder so that people don't cast garbage */ \
int be_sure_to_add_VLC_COMMON_MEMBERS_to_struct; \
/**@}*/

#define VLC_OBJECT( x ) \
((vlc_object_t *)(x))+0*(x)->be_sure_to_add_VLC_COMMON_MEMBERS_to_struct

vlc 函数在使用vlc_object_t该 结构体时,都会首先执行一遍 VLC_OBJECT( x )

但我对于 be_sure_to_add_VLC_COMMON_MEMBERS_to_struct 的使用不是太了解,虽然它加了注释,
我也还是想不明白。
...全文
83 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
iu_81 2008-05-11
  • 打赏
  • 举报
回复
定义一个结构来使用宏定义的公共成员

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧