What is compiler_defs.h?
Compiler_defs.h is a header file provided by Silicon Labs which contains compiler-specific macro definitions which can be used in place of compiler-specific syntax to allow for code to be compiler independent. Each compiler uses different syntax for handling special function registers (SFRs), memory segments, and interrupt declarations. At compile-time, the compiler will replace every macro definition in the C source code with corresponding compilers-specific syntax found in compiler_defs.h. The compiler_defs.h file is organized by compiler using #defines to indicate blocks of macro definitions for each compiler. In the compiler_defs.h file, each supported compiler has a section which includes a #define statement for each macro definition, followed by a macro name with parameters and the corresponding compiler-specific syntax. Macro definitions can be easily modified or added to this file as needed.
Each compiler has its own way of declaring a bit in a bit addressable SFR. For example, if bit 5 in the SFR Port 1 was defined as ‘LED’, using compiler_defs.h it would look like this:
SBIT (LED,SFR_P1, 5); // Port 1 Pin 5
If the Raisonance compiler was used, that particular line of code would be replace with the following line of C code at compile time:
at (P1+5) sbit LED; // Port 1 Pin 5
If the Keil compiler was used, that particular line of code would be replace with the following line of C code at compile time:
sbit LED = P1^5; // Port 1 Pin 5
Compiler_defs.h allows one line of code to work between many compilers. Currently, the compiler_defs.h file contains macro definitions for: