Ofri Rips
Ofri Rips

Reputation: 153

Doxygen warning when using a macro inside an anonymous struct

I have a struct, and by convention, I need to use a certain macro in order to declare a variable of that type:

the struct:

struct basic_struct {
    int a;
    int b;
};

the macro:

#define BASIC_VAR(var_name) struct basic_struct var_name

I encountered a problem with Doxygen when using this macro inside an anonymous struct, as follows:

struct {
    BASIC_VAR(var_1);
    int var_2;
} my_struct;

I get the Doxygen warning:

warning: no uniquely matching class member found for BASIC_VAR(var_1)

when:

1) dropping the macro

struct {
    struct basic_struct var_1;
    int var_2;
} my_struct;

2) not using anonymous struct

 struct my_struct_t {
    BASIC_VAR(var_1);
    int var_2;
} my_struct;

I get no warnings. But I have to use the macro, and I prefer to keep using the anonymous struct, there's any Doxygen command I can use to avoid this warning?

Upvotes: 1

Views: 247

Answers (2)

Fred Larson
Fred Larson

Reputation: 62113

I believe you need to set MACRO_EXPANSION to YES in the Doxyfile so that Doxygen will expand your macro. See http://www.doxygen.nl/manual/preprocessing.html

Additionally, you may need to add your macro to the PREDEFINED tag.

Upvotes: 2

Ofri Rips
Ofri Rips

Reputation: 153

The workaround that I used was to edit the Doxyfile:

1) make sure that MACRO_EXPANSION tag is set to YES

2) in PREDEFINED tag add the macro followed with = operator, without spaces, in my case: BASIC_VAR(var_1)=

For some reason, setting MACRO_EXPANSION tag to YES and EXPAND_ONLY_PREDEF to NO didn't work.

Upvotes: 0

Related Questions