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

Possible bug 709 vs 710 ?

typedef enum { SCREEN_STARTUP,
               SCREEN_SHUTDWN,
             } ScreenType;

void main( void )
{
   while(1);
}

The comma after SCREEN_SHUTDWN causes error C141 in v709 but no error in v710.

Parents
  • Can you be more specific, I always like to learn something new, you may see something I don't know about.

    It's quite simple: according to ANSI/ISO C Standards, the last name in an enum definition is notallowed to be followed by a comma. This is exactly opposite to struct and union definitions, where you're required to terminate the last field definition with a semicolon.

    Your code had such a formally forbidden comma after the second field of your enum, which means it's incorrect.

    In the meantime, a lot of C compilers out there have been extended to not enforce this restriction. From what you showed, Keil detected this error up to version 7.09, but this was changed with 7.10.

    So, to sum it up: even though the behaviour of versions 7.09 and 7.10 differs, in this particular case that doesn't mean either of them must have a bug. The actual bug is in your code, but 7.10 chose to ignore it, because it's harmless.

Reply
  • Can you be more specific, I always like to learn something new, you may see something I don't know about.

    It's quite simple: according to ANSI/ISO C Standards, the last name in an enum definition is notallowed to be followed by a comma. This is exactly opposite to struct and union definitions, where you're required to terminate the last field definition with a semicolon.

    Your code had such a formally forbidden comma after the second field of your enum, which means it's incorrect.

    In the meantime, a lot of C compilers out there have been extended to not enforce this restriction. From what you showed, Keil detected this error up to version 7.09, but this was changed with 7.10.

    So, to sum it up: even though the behaviour of versions 7.09 and 7.10 differs, in this particular case that doesn't mean either of them must have a bug. The actual bug is in your code, but 7.10 chose to ignore it, because it's harmless.

Children