“枚举”之前的预期表达

时间:2019-05-05 19:18:31

标签: c enums expression

我具有以下结构:

typedef struct {
    State state;
} MyStruct;

上面的结构使用以下枚举:

typedef enum State {
    state1,
    state2
} State;

当我想从数组 bars 的元素检查状态时,会在foo函数内部的构建过程中发生错误。错误消息是:

  

“状态”前的预期表达式

MyStruct* bars[ARRAY_SIZE_OF_BARS];

void foo() {
    for (int i = 0; i < ARRAY_SIZE_OF_BARS; i++) {
        if (bars[i]->state == State.state1) { // error at this line
            // code continues
    }
}

ARRAY_SIZE_OF_BARS 在头文件中定义。 我在这里没看到什么?

0 个答案:

没有答案