Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use doxygen to document members of a c structure outside of the structure definition

Tags:

c

doxygen

I am using doxygen to comment my C code. I am making use of a foreign API (i.e. not my own) for which documentation is scarce so I intend to document some of that API within my own source files. I do have the header file for the foreign API but it is not practical to add my own comments to that file.

Foreign Header

struct foreignstruct
{
    int a;
    int b;
};

My Header

/** My structure comments... */
struct mystruct
{
    /** Describe field here... */
    int field;
};

/** @struct foreignstruct
 *  @brief This structure blah blah blah...
 *  @??? a Member 'a' contains...
 *  @??? b Member 'b' contains...
 */

What tag do I use in place of @??? to get the correct doxygen output (where 'correct' means generated output for mystruct and foreignstruct are the same)?

like image 855
Ben Avatar asked Aug 26 '11 01:08

Ben


1 Answers

Maybe one day doxygen will have a special @field tag for this, until that time, the following can be used:

/** @struct foreignstruct
 *  @brief This structure blah blah blah...
 *  @var foreignstruct::a 
 *  Member 'a' contains...
 *  @var foreignstruct::b 
 *  Member 'b' contains...
 */

Which is a short-hand notation for

/** @struct foreignstruct
 *  @brief This structure blah blah blah...
 */
/** @var foreignstruct::a 
 *  Member 'a' contains...
 */
/** @var foreignstruct::b 
 *  Member 'b' contains...
 */
like image 62
doxygen Avatar answered Nov 13 '22 02:11

doxygen