What is the difference between \param[out] and \return in Doxygen? They both seem to document the output / return of a function. Is the difference due to void functions which don’t have a return value and only param[out] would be valid?
What is the difference between \param[out] and \return in Doxygen? They both seem to
Share
Out parameters are different from return values. Take this example in C:
The function returns nothing, but the value to which
variablepoints is changed, hence we call it an output parameter. It represents an ‘output’ of the function in that we expect it to be modified somehow by the function.val, on the other hand, is an ‘input’ parameter because it is not modified (and, indeed, cannot be modified from the perspective of the function’s caller, since it is passed as a value).Here’s a slightly more useful and realistic example:
In this case, we construct some complex object inside the function. We return a simple status flag that lets the user know the object creation was successful. But we pass out the newly-created object using an out parameter.
(Although, of course, this function could easily just return a pointer. Some functions are more complex!)