繁体   English   中英

Doxygen使用默认参数重复c ++函数

[英]Doxygen repeating c++ functions with default arguments

我正在使用Doxygen来记录我的一些代码。 我有一个使用默认参数的函数,它在标题中指定,即:

unsigned int CountColumns(const std::string&,const std::string& delim="");

以及源文件中的相应实现如下:

unsigned int CountColumns(const string& input,const string& delim)
{
   ...
}

当我使用Doxygen生成我的文档时,CountColumns有两个条目 - 一个包含默认值,另一个没有:

unsigned int    CountColumns (const string &input, const string &delim)
unsigned int    CountColumns (const std::string &, const std::string &delim="")

如何避免这种情况? 我不希望多个函数定义混乱我的文档。

编辑:正如我在下面的回答中提到的,问题似乎是由于头文件在参数中使用'std :: string',而源文件包含'using std :: string'声明然后在参数中使用'string'。 如果我改变函数定义以在源文件中使用'std :: string',Doxygen会将其识别为与标头中声明的函数相同的函数。

我建议在配置文件中将BUILTIN_STL_SUPPORT设置为YES ,因此doxygen knows string是std命名空间中定义的类。

问题似乎是由于头文件在参数中使用'std :: string'这一事实,而源文件包含'using std :: string'语句,然后在参数中使用'string'。 如果我改变函数定义以在源文件中使用'std :: string',Doxygen会将其识别为与标头中声明的函数相同的函数。

虽然不理想,但它是一种有效且不太笨重的解决方案。

那么如何从文档中排除额外的功能呢?

这是来自doxygen FAQ

“我如何让doxygen忽略一些代码片段?

新的最简单的方法是在开始时添加一个带有\\cond命令的注释块,并在应该忽略的代码段末尾添加一个带有\\endcond命令的注释块。 当然,这应该在同一个文件中。

但你也可以使用doxygen的预处理器:如果你放了

  #ifndef DOXYGEN_SHOULD_SKIP_THIS /* code that must be skipped by Doxygen */ #endif /* DOXYGEN_SHOULD_SKIP_THIS */ around the blocks that should be hidden and put: PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS in the config file then all blocks should be skipped by Doxygen as long as 

预处理=是。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM