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.
I've done the code below to control the size of my NVM during compile time: . . . typedef enum { NvmAddrStart = 0x0000 ,NvmAddrFactory = (NvmAddrStart) ,NvmAddrFactoryEnd = (NvmAddrFactory + 10) ,NvmLastAddress = (NvmAddrFactoryEnd) }; #if (NvmLastAddress >= 0x0800) #error "MEMORY FULL" #endif . . . What I would like to know is why the above check does not work? See below the error message: C51 COMPILER V7.01 - SN: C1S4P-B3602E COPYRIGHT KEIL ELEKTRONIK GmbH 1987 - 2002 *** WARNING C322 IN LINE 560 OF ../INC\APMS.H: unknown identifier If I put the same check without using an enumerator, only #define directives, in this way it works properly. Is there any limitation concernig the enumerator? Regards Thank you
The expression used in #if must be a preprocessor constant expression, which can involve only integer constants, character constants, and the special defined operator. The preprocessor knows nothing about enumeration constants. Enumerations are a C compiler thing, not a C preprocessor thing.