#if & #error giving C322 Error - enum not defined?

Hi

Here is the code I have problems with
I an just starting to use this C compiler
Have used many others, mainly closer to C99

#define Num_LANGUAGEs 6


enum _LANGUAGE {
	eUSING_LAN_START = -1,	// This is always the First item
	eUSING_ENGLISH,
	eUSING_ITALIAN,
	eUSING_FRENCH_Can,
	eUSING_LAST_LANG	// This is always the Last item
};

#if Num_LANGUAGEs != eUSING_LAST_LANG
#error "Warning Not enough Lang defined"
#endif


Where is a list of C Compiler error defs(Not in manual)?

Manual poor on #if conditionals, where can I find more info?

Where is "cosf" function, for faster math?
Where is source for Libraries?

Parents
  • The preprocessor runs before the C Compiler (this is the way all C compilers work). The preprocessor processes preprocessor directives (those statements that begin with a #).

    The preprocessor creates an output file (This is the *.I file that may be created). The preprocessor output file is the actual file that is compiled.

    The program you provided:

    #define Num_LANGUAGEs 6
    
    enum _LANGUAGE {
    	eUSING_LAN_START = -1,	// This is always the First item
    	eUSING_ENGLISH,
    	eUSING_ITALIAN,
    	eUSING_FRENCH_Can,
    	eUSING_LAST_LANG	// This is always the Last item
    };
    
    #if Num_LANGUAGEs != eUSING_LAST_LANG
    #error "Warning Not enough Lang defined"
    #endif

    includes some C code and some preprocessor code.

    The following line:

    #if Num_LANGUAGEs != eUSING_LAST_LANG

    fails because while the preprocessor knows the value of "Num_LANGUAGEs" (because it is a preprocessor directive #define) it does not know the value of eUSING_LAST_LANG (because it is a C symbol and not a preprocessor symbol).

    Where is a list of C Compiler error defs(Not in manual)?

    There is a chapter of all errors generated by the Compiler in the manual.


    Manual poor on #if conditionals, where can I find more info?

    Preprocessor directives are documented in almost every book on the C programming language.

    Jon

Reply
  • The preprocessor runs before the C Compiler (this is the way all C compilers work). The preprocessor processes preprocessor directives (those statements that begin with a #).

    The preprocessor creates an output file (This is the *.I file that may be created). The preprocessor output file is the actual file that is compiled.

    The program you provided:

    #define Num_LANGUAGEs 6
    
    enum _LANGUAGE {
    	eUSING_LAN_START = -1,	// This is always the First item
    	eUSING_ENGLISH,
    	eUSING_ITALIAN,
    	eUSING_FRENCH_Can,
    	eUSING_LAST_LANG	// This is always the Last item
    };
    
    #if Num_LANGUAGEs != eUSING_LAST_LANG
    #error "Warning Not enough Lang defined"
    #endif

    includes some C code and some preprocessor code.

    The following line:

    #if Num_LANGUAGEs != eUSING_LAST_LANG

    fails because while the preprocessor knows the value of "Num_LANGUAGEs" (because it is a preprocessor directive #define) it does not know the value of eUSING_LAST_LANG (because it is a C symbol and not a preprocessor symbol).

    Where is a list of C Compiler error defs(Not in manual)?

    There is a chapter of all errors generated by the Compiler in the manual.


    Manual poor on #if conditionals, where can I find more info?

    Preprocessor directives are documented in almost every book on the C programming language.

    Jon

Children
More questions in this forum