Doxygen:使用“处理未使用的函数参数”;“未使用”;宏 短版

Doxygen:使用“处理未使用的函数参数”;“未使用”;宏 短版,doxygen,unused-variables,Doxygen,Unused Variables,为了防止编译器对未使用的变量发出警告,我将宏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 ar

为了防止编译器对未使用的变量发出警告,我将宏
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忽略
未使用的

长版本 我有一个如下代码:

#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;
}
要生成名为
Doxyfile
I的默认doxygen配置文件,请输入:

doxygen -g
doxygen Doxyfile
最后,要生成我输入的文档,请执行以下操作:

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'

按照中的说明,修改Doxyfile,使其具有以下参数:

#Doxygen will run its own preprocessor before parsing the file
ENABLE_PREPROCESSING   = YES

#The Doxygen preprocessor will not only define the macros (default
#behaviour) but also expand them
MACRO_EXPANSION        = YES

#The Doxygen preprocessor will only expand the macros that are listed in
#the PREDEFINED setting. Any other macro will merely be defined, and not
#expanded.
EXPAND_ONLY_PREDEF     = YES

#The Doxygen preprocessor will replace any occurrence of the UNUSED
#macro by its argument
PREDEFINED             = UNUSED(x)=x

在这些更改之后,调用
doxygen-Doxyfile
不再发出警告。

按照中的说明,修改Doxyfile,使其具有以下参数:

#Doxygen will run its own preprocessor before parsing the file
ENABLE_PREPROCESSING   = YES

#The Doxygen preprocessor will not only define the macros (default
#behaviour) but also expand them
MACRO_EXPANSION        = YES

#The Doxygen preprocessor will only expand the macros that are listed in
#the PREDEFINED setting. Any other macro will merely be defined, and not
#expanded.
EXPAND_ONLY_PREDEF     = YES

#The Doxygen preprocessor will replace any occurrence of the UNUSED
#macro by its argument
PREDEFINED             = UNUSED(x)=x

在这些更改之后,调用
doxygen-Doxyfile
不再发出警告。

您看过手册中的预处理器部分了吗?也许在doxyfile中预定义的UNUSED(x)可能会有帮助,我只是看了一下:事实上,这里已经解释过了!谢谢你的提示!你看过手册中的预处理器部分了吗?也许在doxyfile中预定义的UNUSED(x)可能会有帮助,我只是看了一下:事实上,这里已经解释过了!谢谢你的提示!