请不要介意以下最小示例的奇怪之处(我必须将其做得更大才能证明我这样做的原因):
文件测试.cpp:
#include "a.h"
int main() {
return 0;
}
文件 a.h:
namespace N { // without namespace all is well!
#include "b.h"
}
文件 b.h:
/// \file
#ifndef GUARD
#define GUARD
struct A {};
#define CMD 5 // without this, all is well!
#endif
Doxygen 1.8.11 提示:
warning: Member GUARD (macro definition) of file a.h is not documented.
第一个有趣的事情是警告提到了a.h
。第二个是,如果删除任一注释行,警告就会消失。这是怎么回事?
最佳答案
您可以使用 conditional documentation至 suppress像这样的 Doxygen 警告:
//b.h
/// \file
//! @cond SuppressGuard
#ifndef GUARD
#define GUARD
//! @endcond
struct A {};
//! @cond SuppressCmd
#define CMD 5 // without this, all is well!
//! @endcond
//! @cond SuppressGuard
#endif
//! @endcond
请注意,我用 cond
包装了 #endif
,否则您将收到 if-endif 不匹配警告:
/home/user/doxygen/b.h:13: warning: More #endif's than #if's found.
关于c++ - Doxygen 要求记录一个 include-guard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40358150/