I have the following file test.c: #define MAX (2U) enum ENUM_EXAMPLE{ a, b, c, d, e, last }; #if( last >= MAX ) #error Last is greater than MAX. #endif
/* * Never get as far as this main when compiling with other code to mater, * need for the standalone test: */ int main( void ) { } If I do 'avr-gcc test.c' I get an a.out file and no errors. If I include test.c in my project I get 'error: "last" is not defined'. Why would it be defined in the standalone one and not defined in the other? Looking in "C: A Reference Manual" 5th edition by Harbison and Steele they make the distinction between "preprocessor constant expressions" and "integral constant expressions" in section 7.11/7.11.1. In 7.11.1 enums are not listed as a allowable type to #if. If that is the case why does the standalone compile of test.c compile? If that is not the case why is 'last' not defined? I'm confused by this inconstancy, what am I overlooking here? The goal in my real code is to know when I've assigned more than 254 enums in one enumerator set. Is there a different way to do this? _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list