简体   繁体   English

在匿名结构中使用宏时的Doxygen警告

[英]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: 在匿名结构中使用此宏时,我遇到了Doxygen的问题,如下所示:

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

I get the Doxygen warning: 我收到Doxygen警告:

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

when: 什么时候:

1) dropping the macro 1)删除宏

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

2) not using anonymous struct 2)不使用匿名结构

 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? 但是我必须使用宏,并且我更喜欢继续使用匿名结构,可以使用任何Doxygen命令来避免此警告?

I believe you need to set MACRO_EXPANSION to YES in the Doxyfile so that Doxygen will expand your macro. 我相信您需要在Doxyfile中将MACRO_EXPANSION设置为YES ,以便Doxygen扩展您的宏。 See http://www.doxygen.nl/manual/preprocessing.html 参见http://www.doxygen.nl/manual/preprocessing.html

Additionally, you may need to add your macro to the PREDEFINED tag. 此外,您可能需要将宏添加到PREDEFINED标记中。

The workaround that I used was to edit the Doxyfile: 我使用的解决方法是编辑Doxyfile:

1) make sure that MACRO_EXPANSION tag is set to YES 1)确保将MACRO_EXPANSION标记设置为YES

2) in PREDEFINED tag add the macro followed with = operator, without spaces, in my case: BASIC_VAR(var_1)= 2)在PREDEFINED标记中,在宏后面加上=运算符,不带空格,在我的情况下:BASIC_VAR(var_1)=

For some reason, setting MACRO_EXPANSION tag to YES and EXPAND_ONLY_PREDEF to NO didn't work. 由于某些原因,将MACRO_EXPANSION标记设置为YES并将EXPAND_ONLY_PREDEF设置为NO无效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM