Cross File Arrays. More...
Cross File Arrays.
This macro, in combination with an entry in the linker scripts, allows the definition of constant arrays to be spread over multiple C compilation units. These arrays are called "cross-file arrays" or short xfa.
Definition in file xfa.h.
Include dependency graph for xfa.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
| #define | _XFA(type, name, prio) |
| helper macro for other XFA_* macros More... | |
| #define | _XFA_CONST(type, name, prio) |
| helper macro for other XFA_* macros More... | |
| #define | XFA_INIT_CONST(type, name) |
| Define a read-only cross-file array. More... | |
| #define | XFA_INIT(type, name) |
| Define a writable cross-file array. More... | |
| #define | XFA_USE_CONST(type, name) XFA_USE(type, name) |
| Declare an external read-only cross-file array. More... | |
| #define | XFA_USE(type, name) |
| Declare an external writable cross-file array. More... | |
| #define | XFA(type, xfa_name, prio) _XFA(type, xfa_name, 5_ ## prio) |
| Define variable in writable cross-file array. More... | |
| #define | XFA_CONST(type, xfa_name, prio) _XFA_CONST(type, xfa_name, 5_ ## prio) |
| Define variable in read-only cross-file array. More... | |
| #define | XFA_ADD_PTR(xfa_name, prio, name, entry) |
| Add a pointer to cross-file array. More... | |
| #define | XFA_LEN(type, name) |
| Calculate number of entries in cross-file array. More... | |
| #define _XFA | ( | type, | |
| name, | |||
| prio | |||
| ) |
| #define _XFA_CONST | ( | type, | |
| name, | |||
| prio | |||
| ) |
| #define XFA | ( | type, | |
| xfa_name, | |||
| prio | |||
| ) | _XFA(type, xfa_name, 5_ ## prio) |
Define variable in writable cross-file array.
Variables will end up sorted by prio.
Add this to the type in a variable definition, e.g.:
XFA(driver_params_t, driver_params, 0) _onboard = { .pin=42 };
| [in] | type | type of the xfa elements |
| [in] | xfa_name | name of the xfa |
| [in] | prio | priority within the xfa |
| #define XFA_ADD_PTR | ( | xfa_name, | |
| prio, | |||
| name, | |||
| entry | |||
| ) |
Add a pointer to cross-file array.
Pointers will end up sorted by prio.
| [in] | xfa_name | name of the xfa |
| [in] | prio | priority within the xfa |
| [in] | name | symbol name |
| [in] | entry | pointer variable to add to xfa |
| #define XFA_CONST | ( | type, | |
| xfa_name, | |||
| prio | |||
| ) | _XFA_CONST(type, xfa_name, 5_ ## prio) |
Define variable in read-only cross-file array.
Variables will end up sorted by prio.
Add this to the type in a variable definition, e.g.:
XFA(driver_params_t, driver_params, 0) _onboard = { .pin=42 };
| [in] | type | type of the xfa elements |
| [in] | xfa_name | name of the xfa |
| [in] | prio | priority within the xfa |
| #define XFA_INIT | ( | type, | |
| name | |||
| ) |
Define a writable cross-file array.
This macro defines the symbols necessary to use XFA_START() and XFA_END(). It needs to be part of one single compilation unit.
The pragmas prevent these errors:
error: ISO C forbids empty initializer braces error: ISO C forbids zero-size array ‘xfatest_end’
| [in] | type | type of the cross-file array |
| [in] | name | name of the cross-file array |
| #define XFA_INIT_CONST | ( | type, | |
| name | |||
| ) |
Define a read-only cross-file array.
This macro defines the symbols necessary to use XFA_START() and XFA_END(). It needs to be part of one single compilation unit.
The pragmas prevent these errors:
error: ISO C forbids empty initializer braces error: ISO C forbids zero-size array ‘xfatest_const_end’
| [in] | type | type of the cross-file array |
| [in] | name | name of the cross-file array |
| #define XFA_LEN | ( | type, | |
| name | |||
| ) |
| #define XFA_USE | ( | type, | |
| name | |||
| ) |
Declare an external writable cross-file array.
This macro defines the symbols necessary to use XFA_START() and XFA_END(). Think of this as XFA_INIT() but with "extern" keyword. It is supposed to be used in compilation units where the cross file array is being accessed, but not defined using XFA_INIT.
| [in] | type | type of the cross-file array |
| [in] | name | name of the cross-file array |
| #define XFA_USE_CONST | ( | type, | |
| name | |||
| ) | XFA_USE(type, name) |
Declare an external read-only cross-file array.
This macro defines the symbols necessary to use XFA_START() and XFA_END(). Think of this as XFA_INIT() but with "extern" keyword. It is supposed to be used in compilation units where the cross file array is being accessed, but not defined using XFA_INIT.
| [in] | type | type of the cross-file array |
| [in] | name | name of the cross-file array |