13

In case I have my documentation separate from my code, how do I help Doxygen distinguish between overloaded functions (what to use in the \fn field)? A single function would be documented like this:

void func() {
}

/**
    \fn func
    \details Description here.
  */

What if I have two functions called func?

void func() {
}

void func(int i) {
}

/**
    \fn [What goes here?]
    \details Description here.
  */
BenMorel
  • 34,448
  • 50
  • 182
  • 322
Paul Manta
  • 30,618
  • 31
  • 128
  • 208

2 Answers2

21

There is an \overload doxygen command for such cases. See the doxygen command reference. Use your regular \fn command for the base case and use \overload for any, well, overload. :)

Basti
  • 373
  • 2
  • 6
  • 12
SolarBear
  • 4,534
  • 4
  • 37
  • 53
6

You can simply document each overload as if it is a separate method (which it is, really :-) - just put the entire method signature in the \fn command instead of just the method's name. As in:

/**
    \fn func()
    \details Description here.
 */
void func() { }

/**
    \fn func(int i)
    \details Description here.
 */
void func(int i) { }

(Sorry, I just had to move the doc comments above the methods where they belong :-)

And indeed, you don't need the \fn command at all, if the comment is directly ahead of the code element it pertains to.

/**
    \details Description here.
 */
void func() { }

/**
    \details Description here.
 */
void func(int i) { }
Jason Williams
  • 56,972
  • 11
  • 108
  • 137