Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

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.

like image 490
rose Avatar asked Sep 27 '22 03:09

rose


1 Answers

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.
 * ...
 */
like image 164
gmug Avatar answered Oct 15 '22 10:10

gmug