繁体   English   中英

Doxygen:我如何记录非#defined的宏?

[英]Doxygen: How can I document macros that are not #defined?

我正在尝试使用Doxygen来记录一些选项控制宏符号的功能,例如:

 //! \def BOOST_SOMEFEATURE
 /*! \brief Option macro that is not normally defined
  *  but can optionally be defined by consumers to activate the option.
 */

但是这不会被编入索引,并且注释将被忽略,因为宏未定义。

只有#define类的,才会在文档中生成Doxygen宏符号条目

#define BOOST_SOMEFEATURE

在标题和其他文件中。

我可以强制宏符号的文档除了令人讨厌的软糖之外

  #undef BOOST_SOMEFEATURE

或者可能包括一个虚拟的.cpp文件,其中包含控制选项的所有宏符号的#define

  #define BOOST_SOMEFEATURE
  #define BOOST_SOMEOTHERFEATURE
  ...

请执行下列操作:

  1. 将以下行添加到Doxyfile:

     PREDEFINED = _DOXYGEN_ 
  2. #define宏放在#ifdef _DOXYGEN_部分中:

     #ifdef _DOXYGEN_ /*! * Documentation describing the BOOST_SOMEFEATURE macro. */ #define BOOST_SOMEFEATURE /*! * Documentation describing the BOOST_SOMEOTHERFEATURE macro. */ #define BOOST_SOMEOTHERFEATURE #endif 

使用此方法,在正常构建期间预处理器不会看到您的宏,但Doxygen会看到它们。

您可以将此部分放在您喜欢的代码中的任何位置:.cpp文件,.h文件,或者如果您愿意,可以创建一个虚拟.cpp文件。

也可以看看

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM