Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doxygen repeating c++ functions with default arguments

Tags:

c++

doxygen

I'm using Doxygen to document some of my code. I've got a function that uses a default argument, which is specified in the header i.e.:

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

and the corresponding implementation in the source file as:

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

When I use Doxygen to generate my documentation, CountColumns has two entries - one including the default value, and one without:

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

How can this be avoided? I don't want multiple function definitions cluttering up my documentation.

EDIT: As I've also mentioned in my answer below, the problem appears to be due to the fact that the header file uses 'std::string' in the arguments, while the source file includes a 'using std::string' statement and then uses 'string' in the arguments. If I alter the function definition to use 'std::string' in the source file also, Doxygen recognises it to be the same function as declared in the header.

like image 490
Wheels2050 Avatar asked Aug 28 '12 19:08

Wheels2050


2 Answers

I suggest to set BUILTIN_STL_SUPPORT to YES in your configuration file, so doxygen knows string is a class defined in the std namespace.

like image 162
doxygen Avatar answered Nov 02 '22 13:11

doxygen


The problem appears to be due to the fact that the header file uses 'std::string' in the arguments, while the source file includes a 'using std::string' statement and then uses 'string' in the arguments. If I alter the function definition to use 'std::string' in the source file also, Doxygen recognises it to be the same function as declared in the header.

While not ideal, it is a solution that works and is not too unwieldy.

like image 35
Wheels2050 Avatar answered Nov 02 '22 12:11

Wheels2050