We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
typedef enum { SCREEN_STARTUP, SCREEN_SHUTDWN, } ScreenType; void main( void ) { while(1); }
I'd be tempted to call that one a feature!
Strictly speaking, that code is (slightly) buggy. It was probably more by oversight than by explicit design, but yes, trailing commas in enums were actually not allowed by the 1990 version of C Standard (C99 fixed that). That said, it's a very common relaxation to allow this syntax violation to make automatic code editing a bit easier.
Strictly speaking, that code is (slightly) buggy Can you be more specific, I always like to learn something new, you may see something I don't know about. Thanks.. BTW: I posted just the bare minimum of code, in other reditions I used the enum ScreenType in the main function to make sure it wasn't optimized out, but v709 still caught the trailing comma. I havent tried yet, but I would think that this would also fail LINT for the trailing comma with a warning or error.
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.
Thanks Hans I appreciate the input. I just want to add that I posted the code with the extra comma intentionally, just incase somebody wanted to copy and run it for themselves. If I left it out then it would not generate any error on both V709 or V710. EOM.