氧要求包含保护文件

Doxygen demands that an include-guard be documented

本文关键字:保护 文件 包含      更新时间:2023-10-16

请不要介意下面这个最小的例子的奇怪之处(我必须把它做得更大来证明为什么我这样做):

文件test.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

氧1.8.11抱怨:

warning: Member GUARD (macro definition) of file a.h is not documented.

第一个有趣的事情是警告提到了a.h。第二个问题是,如果任何注释行被删除,警告就会消失。这是怎么回事?

您可以使用条件文档来抑制氧气警告,如:

//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 s包装了#endif,否则你会得到if-end不匹配警告:

/home/user/doxygen/b.h:13: warning: More #endif's than #if's found.