rose
rose

Reputation: 347

How do you link (reference) a member of a structure using Doxygen?

I would like to "link" to a structure or member of a structure in Doxygen while displaying the text struct.member. My source code is in C.

For example, let's say I have the myStruct type/structure in C:

typedef struct
{
    int member1;
    int member2;
} myStruct;

And I would like to link/redirect within my Doxygen comments to documentation on myStruct while showing the text "myStruct.member1"

Example Doxygen Comments for a function:
You will receive the error code MEMBER_1_NOT_VALID if myStruct.member1 is larger than 5.

Where clicking on "myStruct.member1" redirects me to the documentation for myStruct.

I know that if I just have myStruct I could say "\ref myStruct", but doing "\ref myStruct.member1" does not work. Does anyone know how to make the documentation references work?

Any help is appreciated! Thank you.

Upvotes: 7

Views: 11460

Answers (1)

gmug
gmug

Reputation: 785

I think the problem is that you defined the type and the structure together. Doxygen's parser seems to have problems with the mixed declaration of a struct and a typedef. Try to define the structure and the type definition seperately:

struct myStruct_s
{ 
    int member1;
    int member2;
};

typedef struct myStruct_s myStruct;

The you can reference the struct members using the tag name of the struct similar to as you already tried:

/**
 * ...
 * You will receive the error code MEMBER_1_NOT_VALID if \ref myStruct_s.member1 
 * is larger than 5.
 * ...
 */

Upvotes: 6

Related Questions