c++ - Doxygen 要求记录一个 include-guard

标签 c++ doxygen include-guards

请不要介意以下最小示例的奇怪之处(我必须将其做得更大才能证明我这样做的原因):

文件测试.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 documentationsuppress像这样的 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/

相关文章:

c++ - mem_fun + bind2nd 允许使用任意类型的参数调用方法

python - Python 中 doxygen 样式文档字符串的 Vim 语法高亮显示

c - 如何在文档中显示常量变量或宏

c++ - 即使在命名空间之间,包含守卫是否应该是唯一的?

c++ - 在 C++ 中很好地格式化数字

c++ - 在 Release模式下调用 delete 时未删除 fstreams

c++ - g++ 未报告未实例化模板中的某些错误

php - Doxygen:@var 使用命名空间

c++ - 在 C++ 中, "_MOVE_H"有什么特别之处?

c++ - 生成 C++ 在 Atom 中包含 header 保护?