15

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.
  */

2 Answers 2

22

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. :)

Sign up to request clarification or add additional context in comments.

Comments

7

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) { }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.