> From: graceindustr...@gmail.com
[...]
> So that explains the difference.  Seems like there could be a better
> error message for this case, 'don't use enum here', alas "The
> preprocessor does not know anything about types in the language"...

Here's a cute/ugly little macro that might help you find the errors you're 
looking for:

#define ctassert(n,e) extern unsigned char n[(e)?0:-1]

Here's an example of how you might use it:

enum{a,b,c,d,last};
#define MAX 2
ctassert(big_enough,(last <= MAX));

Note that the macro does not need to be invoked from within a function.  If the 
test fails, the error message is almost pretty good, depending on what you 
choose for the array name (sztest.c:6: error: size of array `big_enough' is 
negative).

Refinements of the concept left as an exercise for the reader.  Regards,

   -=Dave
                                          
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to