Compiler Abstraction
Normative
Macros that keep driver source portable across compilers and memory architectures. Where the
MCU/compiler has special keywords for memory addressing (e.g. far / near), declarations
MUST be wrapped with these macros; where it does not, wrapping is not mandatory but the macro
definitions MUST still exist. Keywords per Requirement Keywords.
Basics
Available via Compiler.h:
Symbol |
Meaning |
|---|---|
|
Null pointer, |
|
Compiler-specific inline keyword (empty if inlining is unsupported). |
|
Compiler-specific inline keyword with static scope (empty if unsupported). |
Memory class macros
Memory classes name where an object lives so declarations stay portable. AUTOMATIC, TYPEDEF
come from Compiler.h; the rest are module-specific and defined in Compiler_Cfg.h. Each
developer delivers a Compiler_Cfg.h for their module; the integrator merges them into one and
maps each class to the required memory keyword.
Memory class |
Used for |
Defined in |
|---|---|---|
|
Local pointer declarations (empty definition). |
|
|
Type definitions (empty definition). |
|
|
Pointers to HW special-function registers. |
|
|
Code. |
|
|
Global / static constants. |
|
|
Pointers to application data from another component (ROM or RAM). |
|
|
Pointers to application constants from another component. |
|
|
Global / static variables (see the memory-mapping keywords in Naming Conventions). |
|
Declaration macros
All available via Compiler.h. Each wraps a raw declaration so the memory/pointer class is applied
portably. In the signatures below, variable_type / return_type is the underlying type,
memory_class the class of the object itself, and pointer_class the class of the pointed-to
object.
Macro |
Use |
|---|---|
|
A variable declaration. |
|
A constant declaration. |
|
Pointer to a variable. |
|
Pointer to a constant. |
|
Constant pointer to a variable. |
|
Constant pointer to a constant. |
|
Function-pointer type. |
|
Constant function-pointer type. |
|
A function declaration/definition. |
|
A function returning a pointer to a variable. |
|
A function returning a pointer to a constant. |
Example — the raw declaration and its wrapped form:
/* raw (qualifier order is compiler-dependent) */
MEM_CLASS uint32 a_variable;
PTR_CLASS uint32 * MEM_CLASS a_pointer;
<MIP>_CODE uint32 Mip_Function(uint32 param);
/* wrapped */
VAR(uint32, MEM_CLASS) a_variable;
P2VAR(uint32, MEM_CLASS, PTR_CLASS) a_pointer;
FUNC(uint32, <MIP>_CODE) Mip_Function(uint32 param);