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
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
I found that symbol in the version 5 handbook also... But I'm not sure if it's useful or not. I need: #ifdef __C51__ //Keil-specific stuff #endif but, since __C51__ returns the version number, that becomes: #ifdef 5 //Keil-specific stuff #endif So I could do something like: #if __C51__>0 //Keil-specific stuff #endif But that wouldn't work on other compilers because the symbol wouldn't be defined at all. Is there another way to use this symbol to get what I want? Thanks for your help!
In the v6.03 manual, "C51 Compiler User's Guide 03.2000," it's on p112, entitled "Predefined Macro Constants" __C51__ gives you the version of C51 There's also a NOEXTEND directive, which disables all the Keil extensions to ANSI C. Don't forget that you'll need to consider byte ordering, data sizes, etc, as well as the 'C' language extensions!