带有 *.in 文件的 Doxygen

Doxygen with *.in file

我用 *.in 文件生成函数

   class Foo
   {
   public:
   ...

      #define FUNCTION(returnType, getterName) \
         returnType getterName(uint8_t iValue) const;
      #include "Functions.in"
      #undef FUNCTION

   ...
   };

并想使用 Doxygen。 Doxygen 配置如下:

...
INPUT                  = Path/To/Foo
...
FILE_PATTERNS          = *.in \
                         *.c \
                         *.cc \
                         *.cxx \
                         *.cpp \
                         *.c++ 
...
SEARCH_INCLUDES        = YES
...
INCLUDE_PATH           = Path/To/Foo
...

我可以在文档中看到 *.in 文件,但在 class 中看不到函数。此外,Doxygen 会创建以下警告

Foo.h:10: warning: include file Functions.in not found, perhaps you forgot to add its directory to INCLUDE_PATH?

有人知道如何在 *.in 文件中使用 Doxygen 吗?实际上可以将 Doxygen 与生成代码一起使用吗?

如果你阅读 the Doxygen preprocessing documentation 你会看到

Source files that are used as input to doxygen can be parsed by doxygen's built-in C-preprocessor.

By default doxygen does only partial preprocessing. That is, it evaluates conditional compilation statements (like #if) and evaluates macro definitions, but it does not perform macro expansion.

可以更改此默认行为:

In case you want to expand the CONST_STRING macro, you should set the MACRO_EXPANSION tag in the config file to YES.

所以解决方案是不是 运行 *.in 文件通过Doxygen,而是将MACRO_EXPANSION 配置变量设置为YES,宏将被完全展开,它们的展开应该被解析。