Doxygen:如何使用 EXPAND_AS_DEFINED
我定义了以下宏,并尝试在生成文档时扩展它。
#define GETSET(param) \
bool CYNOVE_Enable##param(postproc_ctx_t ctx, bool enable) \
{ \
struct postproc_ctx * c; \
c = (struct postproc_ctx *)ctx; \
c->do_##param = enable?1:0; \
return TRUE; \
} \
在 doxygen 中,如果我使用 :
MACRO_EXPANSION = YES
那么当我使用它时宏会被扩展。 但是,如果设置:
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
EXPAND_AS_DEFINED = GETSET
宏不会扩展,
因为我认为,其中一个答案是错误的,但评论对于任何冗长的解释都很糟糕,让我补充一下我认为这应该如何工作。
根据 doxygen 文档和此链接,PREDEFINED 和 EXPAND_AS_DEFINED 提供不同的服务目的。我理解 EXPAND_AS_DEFINED 用于选择性地扩展给定的宏“因为它是在源代码中定义的”,因此得名,而 PREDEFINED 在这里赋予 Doxygen 宏的含义。
I have defined the following macros, and try to have it expanded when generating documentation.
#define GETSET(param) \
bool CYNOVE_Enable##param(postproc_ctx_t ctx, bool enable) \
{ \
struct postproc_ctx * c; \
c = (struct postproc_ctx *)ctx; \
c->do_##param = enable?1:0; \
return TRUE; \
} \
In doxygen, if I use :
MACRO_EXPANSION = YES
Then the macro is expanded when I use it.
However if set :
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
EXPAND_AS_DEFINED = GETSET
the macro is not expanded
Since I think, one of the answer is wrong, but the comment just suck for any lengthy explanation, let me add how I think this should work.
According to the doxygen documentation and this link, PREDEFINED and EXPAND_AS_DEFINED serve different purpose. I understood that EXPAND_AS_DEFINED is used to selectively expand a given macro "as it was defined in the source code", hence the name, while PREDEFINED is here to give Doxygen the meaning of a macro.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为正如其名称所示,如果这样放置,它只会扩展预定义的宏。您应该
在 Doxygen 文件中放入类似的内容。
顺便说一句,由于您使用的是
bool
:enable?1:0
应该只是enable
,bool
没有别的比 C 中的0
和1
更好。TRUE
应该是true
I think it is as the name says, it will only expand predefined macros if put that way. You should put something like
in your Doxygen file.
BTW, since you are using
bool
:enable?1:0
should just beenable
,bool
are nothing else than0
and1
in C.TRUE
should betrue
我使用提问者的配置选项对其进行了测试,并且宏正常扩展。不知道doxygen更新是否解决了这个问题。
我的版本:在源文件上配置和运行 doxygen 版本 1.9.4 的工具。
tc
另外,你可以使用
-d preprocessor
来检查宏扩展后的代码是什么样子的。I tested it using the questioner's configuration options, and the macro expanded normally. I don't know if the doxygen update has fixed this issue.
My version: A tool to configure and run doxygen version 1.9.4 on your source files.
t.c
In addition, you can use
-d preprocessor
to check what the code looks like after macro expansion.