Compiler Abstraction
Aus automotive wiki
The compiler abstraction specifies definitions and macros for the abstraction of compiler specific keywords used for addressing data and code (pointers, variables, function etc.) within declarations and definitions.
The file Compiler_Cfg.h contains the module / component specific parameters (ptrclass and memclass) that are passed to the macros defined in Compiler.h.
Definitions
|
Define |
Description |
|
AUTOMATIC |
Empty definition, used for the declaration of local pointers. |
|
TYPEDEF |
Empty definition, used within type definitions, where no memory qualifier can be specified. |
|
NULL_PTR |
NULL Pointer ((void *)0) |
|
INLINE |
Define for abstraction of the keyword “inline”. |
|
LOCAL_INLINE |
Define for abstraction of the keyword “inline” in functions with “static” scope. |
Memory Classes and Pointer Classes
In the following table the is derived from the Software Component’s shortName.
|
Memory type |
Syntax of memory class (memclass) and pointer class (ptrclass) macro parameter |
To be used for… |
|
Code |
_CODE |
code |
|
Constants |
_CONST |
global or static constants |
|
Pointer |
_APPL_DATA |
references on application data (expected to be in RAM or ROM) passed via API |
|
Pointer |
_APPL_CONST |
references on application constants (expected to be certainly in ROM, for instance pointer of Init-function) passed via API |
|
Pointer |
_APPL_CODE |
references on application functions. (e.g. call back function pointers) |
|
Variables |
_CALLOUT_CODE |
references on application functions. (e.g. callout function pointers) |
|
Variables |
_VAR_NOINIT |
all global or static variables that are never initialized |
|
Variables |
_VAR_POWER_ON_INIT |
all global or static variables that are initialized only after power on reset |
|
Variables |
_VAR_FAST |
all global or static variables that have at least one of the following properties:
|
|
Variables |
_VAR |
global or static variables that are initialized after every reset. |
|
Variables |
AUTOMATIC |
local non static variables |
|
Type Definitions |
TYPEDEF |
type definitions where no memory qualifier can be specified. |
Macros for Functions, Pointers, Constants and Variables
These macros ensure correct syntax of definitions and declarations independent of any specific compiler.
|
Short description and example |
Function declaration and definition FUNC( void, SwctShortName_CODE ) RunnableCode( void ); |
Function returning a pointer to a constant FUNC_P2CONST( uint16, _PBCFG, SwctShortName_CODE ) ExampleFunction( void ); |
Function returning a pointer to a variable FUNC_P2VAR( uint16, _PBCFG, SwctShortName_CODE ) ExampleFunction( void ); |
Pointer to variable P2VAR( uint8, SPI_VAR_FAST, SPI_APPL_DATA ) Spi_FastPointerToApplData; |
Pointer to constant P2CONST( Eep_ConfigType, EEP_VAR, EEP_APPL_CONST ) Eep_ConfigurationPtr; |
Constant pointer to variable CONSTP2VAR( uint8, NVM_VAR, NVM_APPL_DATA ) NvM_PointerToRamMirror = Appl_RamMirror; |
Constant pointer to constant CONSTP2CONST( Can_PBCfgType, CAN_CONST, CAN_PBCFG_CONST ) Can_PostbuildCfgData = CanPBCfgDataSet; |
Pointer to function typedef P2FUNC( void, NVM_APPL_CODE, NvM_CbkFncPtrType )(void); |
Constant CONST( uint8, NVM_CONST ) NvM_ConfigurationData; |
Variable VAR( uint8, AUTOMATIC ) NvM_VeryFrequentlyUsedState; |
fctname: function name respectively name of the defined type memclass: classification of the function/pointer/constant/variable itself ptrclass: classification of the pointer’s distance →13.1.2 |
|
Macro usage (define) |
FUNC( rettype, memclass ) |
FUNC_P2CONST(rettype, ptrclass, memclass) |
FUNC_P2VAR(rettype, ptrclass, memclass) |
P2VAR(ptrtype, memclass, ptrclass) |
P2CONST(ptrtype, memclass, ptrclass) |
CONSTP2VAR (ptrtype, memclass, ptrclass) |
CONSTP2CONST(ptrtype, memclass, ptrclass) |
P2FUNC(rettype, ptrclass, fctname) |
CONST(consttype, memclass) |
VAR(vartype, memclass) |
vartype: type of the variable consttype: type of the constant retype: return type of the function ptrtype: type of the referenced variable/constant |
|
Macro |
FUNC |
FUNC_P2CONST |
FUNC_P2VAR |
P2VAR |
P2CONST |
CONSTP2VAR |
CONSTP2CONST |
P2FUNC |
CONST |
VAR |
