0

我正在尝试编译一个依赖 sparse 0.4.1 的项目,但在尝试编译 sparse 0.4.1 时,我最终遇到以下编译器错误:

included from parse.c:25:
./parse.h:63:22: error: member of anonymous struct redeclares 'label_statement'
                        struct statement *label_statement;
                                          ^
./parse.h:40:22: note: previous declaration is here
                        struct statement *label_statement;

这让我很困惑,因为它们是两个不同结构的不同成员,所以为什么抱怨呢?

代码如下所示:

struct statement {
    enum statement_type type;
    struct position pos;
    union {
            struct /* declaration */ {
                    struct symbol_list *declaration;
            };
            struct /* label_arg */ {
                    struct symbol *label;
                    struct statement *label_statement;
            };
            struct {
                    struct expression *expression;
                    struct expression *context;
            };
            struct /* return_statement */ {
                    struct expression *ret_value;
                    struct symbol *ret_target;
            };
            struct /* if_statement */ {
                    struct expression *if_conditional;
                    struct statement *if_true;
                    struct statement *if_false;
            };
            struct /* compound_struct */ {
                    struct statement_list *stmts;
                    struct symbol *ret;
                    struct symbol *inline_fn;
                    struct statement *args;
            };
            struct /* labeled_struct */ {
                    struct symbol *label_identifier;
                    struct statement *label_statement;
            };
.......
4

1 回答 1

2

你在同一个 union 中声明语句 label_statement 两次,第一次在第 40 行,第二次在第 63 行

     struct statement *label_statement;

尝试编辑第二个的名称。

于 2012-11-21T00:30:59.663 回答