2016-11-01 41 views
5

请不要介意下面的小例子的陌生感Doxygen的要求(我会让它更大的证明,为什么我做的事情这样):,一个包括后卫被记录

档测试。 CPP:

#include "a.h" 

int main() { 
    return 0; 
} 

文件啊:

namespace N { // without namespace all is well! 
#include "b.h" 
} 

文件BH:

/// \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。第二个是如果任何一条评论行被删除,警告消失。这里发生了什么?

+0

'啊'没有包括守卫? –

+0

@old_mountain仅用于示例的最小化。 – AlwaysLearning

回答

0

您可以使用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 

注意,我包#endifcond S,否则你会得到IF-ENDIF不匹配的警告:

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

这是一种解决方法。但是发生了什么?为什么当我没有定义'CMD'时警告消失了? – AlwaysLearning