This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

expected identifier error

Hello everyone,

I've been trying to make a struct and compiler gives me expected identifier error. Can anyone tell me where is my fault?

struct State {
  unsigned long Out1;
        unsigned long out2;
  unsigned long Time;
  unsigned long Next[8];};

        typedef const struct State STyp;
        #define gow 0;
        #define waitw 1;
        #define gos 2;
        #define waits 3;
        #define gop 4;
        #define fastp 5;

        STyp FSM[6]={
        {0x0c,0x02,500,{gow,gow,wait,waitw,waitw,wait,wait,wait }},//error: expected'}' error: expected identifier or '('
        {0x14,0x02,200,{gos,gos,gos,gos,gop,gop,gos,gos}},
        {0x21,0x02,500,{gos,waits,gos,waits,waits,wait,waits,waits}},
        {0x22,0x02,200,{gow,gow,gow,gow,gop,gow,gop,gop}},
        {0x24,0x08,500,{gop,fastp,fastp,fastp,gop,fastp,fastp,fastp}},
        {0x24,0x02,200,{gow,gow,gos,gow,gow,gow,gos,gow}}}; //error: extraneous closing brance ('}')

Thank you,

Parents
  • "Interesting. I've never used one compiler which reports (or even detects) that one."

    gcc -Wall (or -Wswitch) can give:

    warn_enum.c:10:12: warning: enumeration value âState3â not handled in switch [-Wswitch]
    

    gcc does not emit any warnings if the switch has a default: case.

    The warning is emitted if an enum-typed variable is used. So

    int eval_state(State state) {
        switch (state) {
            case State1: return 1;
            case State2: return 2;
        }
        return -1;
    }
    


    does give a warning, while the use of an int variable like:

    int eval_state(int state) {
        switch (state) {
            case State1: return 1;
            case State2: return 2;
        }
        return -1;
    }
    


    does not give a warning.

    It doesn't hurt to take advantage of whatever "lint" capabilities a compiler may have.

Reply
  • "Interesting. I've never used one compiler which reports (or even detects) that one."

    gcc -Wall (or -Wswitch) can give:

    warn_enum.c:10:12: warning: enumeration value âState3â not handled in switch [-Wswitch]
    

    gcc does not emit any warnings if the switch has a default: case.

    The warning is emitted if an enum-typed variable is used. So

    int eval_state(State state) {
        switch (state) {
            case State1: return 1;
            case State2: return 2;
        }
        return -1;
    }
    


    does give a warning, while the use of an int variable like:

    int eval_state(int state) {
        switch (state) {
            case State1: return 1;
            case State2: return 2;
        }
        return -1;
    }
    


    does not give a warning.

    It doesn't hurt to take advantage of whatever "lint" capabilities a compiler may have.

Children