【发布时间】:2016-03-30 09:50:18
【问题描述】:
短版
为了防止编译器对未使用的变量发出警告,我将宏 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的默认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'
【问题讨论】:
-
您看过手册的预处理器部分吗?也许 UNUSED(x) 的 doxyfile 中的 PREDEFINED 可能会有所帮助
-
我刚刚看了doxygen's doc on preprocessing:确实,那里都解释了!感谢您的提示!