精简版
为了防止编译器对未使用的变量发出警告,我将宏定义UNUSED
为:
UNUSED(x)=x __attribute__((__unused__))
然后在某些函数的原型中使用该宏,例如:
void ext(int foo, int UNUSED( bar ) )
然而,doxygen 对此并不满意并返回一些警告:
/tmp/sandbox/main.cpp:13: warning: argument 'bar' of command @param is not found in the argument list of Dummy::ext(int foo, intUNUSEDbar)
/tmp/sandbox/main.cpp:13: warning: The following parameters of Dummy::ext(int foo, intUNUSEDbar) are not documented:
parameter 'UNUSED'
我应该如何告诉 doxygen 忽略UNUSED
宏?
长版
我有一个如下所示的代码:
#include <iostream>
class Dummy
//! Dummy class
{
public :
//!Dummy function
/**
* \param foo First variable
* \param bar Second variable
*/
void ext(int foo, int UNUSED( bar ) )
{
std::cout << "foo = " << foo << std::endl;
}
};
//!Main function
int main(void)
{
Dummy MyDummy;
MyDummy.ext(1, 2);
return 0;
}
我通过调用来编译它:
g++ -D 'UNUSED(x)=x __attribute__((__unused__))' main.cpp
要生成名为Doxyfile
I 的默认 doxygen 配置文件,请输入:
doxygen -g
最终,要生成我输入的文档:
doxygen Doxyfile
后一个命令输出以下警告:
/tmp/sandbox/main.cpp:13: warning: argument 'bar' of command @param is not found in the argument list of Dummy::ext(int foo, intUNUSEDbar)
/tmp/sandbox/main.cpp:13: warning: The following parameters of Dummy::ext(int foo, intUNUSEDbar) are not documented:
parameter 'UNUSED'