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

Predefined symbols in C51

Where can I find a list of predefined symbols for C51? I'm trying to write a set of portable library routines and I can't figure out how to tell that the file is being compiled by C51..

So I can do something like:
#ifdef __keil_c51__
//keil specific routines
#endif

I'm using an old version of the compiler, v5.10.

Thanks in advance..

Scott

Parents
  • No, #ifdef __C51__ is exactly what you want!
    This is a pre-processor construct which tests whether or not the pre-processor symbol __C51__ is defined; it does not expand the symbol!

    This is the standard way to check what model of compiler you have; eg,

    #if defined __C51__
    //Keil-specific stuff
    #elif defined __BORLANDC__
    //Borland-specific stuff
    #elif defined _MSC_VER
    //MSVC-specific stuff
    #else
    #error Unsupported compiler
    #endif

    Having determined that the compiler version symbol is defined, you could then further test its value for version-specific requirements.

    Note that uVision's syntax colouring does not recognise the 'defined' keyword!

Reply
  • No, #ifdef __C51__ is exactly what you want!
    This is a pre-processor construct which tests whether or not the pre-processor symbol __C51__ is defined; it does not expand the symbol!

    This is the standard way to check what model of compiler you have; eg,

    #if defined __C51__
    //Keil-specific stuff
    #elif defined __BORLANDC__
    //Borland-specific stuff
    #elif defined _MSC_VER
    //MSVC-specific stuff
    #else
    #error Unsupported compiler
    #endif

    Having determined that the compiler version symbol is defined, you could then further test its value for version-specific requirements.

    Note that uVision's syntax colouring does not recognise the 'defined' keyword!

Children
No data