The compiler_defs.h file contains macros and defines for common compiler-specific syntax. For example, the file contains:
Instead of using the const keyword, use code. The const keyword only generates compiler warnings if the code attempts to write to the const variable, but it doesn't specifically locate the variable in a particular place.
Port the Code Slowly
When porting a multi-source project file to another compiler, compile each file separately and handle the compiler errors first. Then try to build the project and catch all of the linker errors.
Static Index Variables
Static index variables should explicitly be declared as type near. This can be accomplished using the SEGMENT_VARIABLE() macro in compiler_defs.h using the explicit segment type SEG_NEAR. This evaluates to data in all other (non Hi-Tech) compilers. This allows the project to be compiled with Hi-Tech, where a problem with the small memory model causes a 'Can't generate code for this line' error.
Timer Reload Values
To avoid warnings with some compilers, define assignments to timer reload values (and similar SFR assignments) as follows:
TMR2RLL = (U8) ((-counts) & 0xFF); TMR2RLH = (U8) ((-counts >> 8) & 0xFF);