[英]How to have macros expanded by doxygen, but not documented as a define?
Say I have: 说我有:
#define MY_MACRO(FOO) void FOO();
MY_MACRO(hi);
MY_MACRO(hey);
MY_MACRO(hello);
#undef MY_MACRO
I want the macros to be expanded by doxygen, which I am able to do by configuring it the right way: 我希望通过doxygen扩展宏,我可以通过正确的方式配置它来完成:
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
EXPAND_AS_DEFINED = MY_MACRO
This enables me to see the expanded result of the macros as documented APIs in the doxygen output (functions hi
, hey
, and hello
). 这使我能够在doxygen输出中看到宏的扩展结果(函数hi
, hey
和hello
)。 That is all good so far. 到目前为止,这一切都很好。 But the problem is that, doxygen also documents MY_MACRO
as a define. 但问题是,doxygen还将MY_MACRO
为定义。 However, I do not want the clients of the API to know about MY_MACRO
, since it is undefed and is not usable by them, and should not be visible to them. 但是,我不希望API的客户端知道MY_MACRO
,因为它没有用,并且不能被它们使用,并且不应该对它们可见。
I have EXTRACT_ALL = YES
in my doxygen configuration and I do not want to change that. 我的doxygen配置中有EXTRACT_ALL = YES
,我不想改变它。 I have tried the following configuration without success: 我尝试了以下配置但没有成功:
PREDEFINED = DOXYGEN_SKIP_FOR_USERS
With the following code: 使用以下代码:
#ifndef DOXYGEN_SKIP_FOR_USERS
#define MY_MACRO(FOO) void FOO();
#endif /*DOXYGEN_SKIP_FOR_USERS*/
MY_MACRO(hi);
MY_MACRO(hey);
MY_MACRO(hello);
#undef MY_MACRO
This hides the documentation of the define, but of course prevents the expansion, so I do not get the functions documented in the generated API. 这隐藏了define的文档,但当然会阻止扩展,所以我没有得到生成的API中记录的函数。
I would appreciate your help. 我很感激你的帮助。
Supposing that MY_
is the prefix that you are using consistently in your code :) I would use the prefix MY__
(two underscores) for internal macros and then put something like 假设MY_
是您在代码中始终使用的前缀:)我会使用前缀MY__
(两个下划线)作为内部宏,然后放置类似的东西
EXCLUDE_SYMBOLS = MY__*
in the Doxygen
configuration file. 在Doxygen
配置文件中。
Edit: the double underscore inside symbols is reserved for C++ (not for C). 编辑:内部符号的双下划线是为C ++保留的(不适用于C)。 So if you want to be compatible with C and C++ you should choose some other type of convention. 因此,如果您想要与C和C ++兼容,您应该选择其他类型的约定。 Unfortunately a leading underscore is reserved, too, so _MY_
wouldn't do neither. 不幸的是,前导下划线也是保留的,所以_MY_
也不会这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.