Doxygen要求记录包含防守

Alw*_*ing 5 c++ doxygen include-guards

请不要介意以下最小例子的陌生感(我必须把它做得更大才能证明我为什么这样做):

文件test.cpp:

#include "a.h"

int main() {
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

档案啊:

namespace N { // without namespace all is well!
#include "b.h"
}
Run Code Online (Sandbox Code Playgroud)

文件bh:

/// \file

#ifndef GUARD
#define GUARD

struct A {};
#define CMD 5 // without this, all is well!

#endif
Run Code Online (Sandbox Code Playgroud)

Doxygen 1.8.11抱怨:

warning: Member GUARD (macro definition) of file a.h is not documented.
Run Code Online (Sandbox Code Playgroud)

第一个有趣的事情是警告提到a.h.第二个是如果删除了任何一条注释行,警告就会消失.这里发生了什么?

Ser*_*gey 0

您可以使用条件文档抑制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
Run Code Online (Sandbox Code Playgroud)

请注意,我用 s 包裹起来#endifcond否则你会收到 if-endif 不匹配警告:

/home/user/doxygen/b.h:13: warning: More #endif's than #if's found.
Run Code Online (Sandbox Code Playgroud)