SPRUIG8J January 2018 – March 2024
To access linker symbols that represent integer values, use the _symval built-in operator, which is essentially a cast operation.
For example, the linker symbol __TI_STACK_SIZE evaluates to a plain integer. To get the symbol's value as an integer in C/C++ code, use the following syntax:
extern void __TI_STACK_SIZE;
size_t get_stack_size() { return _symval(&__TI_STACK_SIZE); }
The type in such extern declarations does not matter, because only the address of the symbol is needed. In strict ANSI mode, you cannot declare this variable with a type of void, so use unsigned char instead.
To understand why the _symval operator is needed to access linker-defined integer values, see Section 12.6.4 for information about how linker symbols differ from C identifiers.