This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

preprocessor bug?

#define SYSYEM LINUX



#if SYSTEM == LINUX
#define HDR "linux.h"
#elif SYSTEM == WINDOWS
#define HDR "windows.h"
#elif SYSTEM == C51
#define HDR "c51.h"
#else
#define HDR "default.h"
#endif
#include HDR


I would expect this to work, but I just keep getting "warning C322: unknown identifier" errors. whats wrong?

Parents
  • #if SYSTEM == LINUX

    turns into

    #if LINUX ==

    which then turns into

    #if ==


    Close, but no cigar... Names found in #if expressions that don't have any
    definition are replaced by literal zeros, not by nothing at all. I.e. the above resolves to

    #if 0L == 0L

    which finally evaluates to true.

    I.e.: in a preprocessor statement, everthing finally is expanded to a number.

    Note that this does not happen in ordinary C source lines. LINUX mentioned elsewhere will not turn into a zero.

Reply
  • #if SYSTEM == LINUX

    turns into

    #if LINUX ==

    which then turns into

    #if ==


    Close, but no cigar... Names found in #if expressions that don't have any
    definition are replaced by literal zeros, not by nothing at all. I.e. the above resolves to

    #if 0L == 0L

    which finally evaluates to true.

    I.e.: in a preprocessor statement, everthing finally is expanded to a number.

    Note that this does not happen in ordinary C source lines. LINUX mentioned elsewhere will not turn into a zero.

Children