SPNU118Z September 1995 – March 2023 66AK2E05 , 66AK2H06 , 66AK2H12 , 66AK2H14 , AM1705 , AM1707 , AM1802 , AM1806 , AM1808 , AM1810 , AM5K2E04 , OMAP-L132 , OMAP-L137 , OMAP-L138 , SM470R1B1M-HT , TMS470R1A288 , TMS470R1A384 , TMS470R1A64 , TMS470R1B1M , TMS470R1B512 , TMS470R1B768
Weak symbol references may or may not have a definition after the final link is performed. If a symbol is undefined, its address is considered to be 0. C/C++ code must check the address of weak references to make sure the value is not 0 before attempting to use the contents of that variable.
extern __attribute__((weak)) unsigned char * foo;
if (&foo != 0)
*foo = 1;
If the linker symbol corresponding to foo might not have a valid address (for instance, because the symbol contains an integer value instead of an address) or might be beyond the 2 GB reach of PC-relative addressing, use the _symval built-in operator as follows:
extern __attribute__((weak)) unsigned char * foo;
if (_symval(&foo) != 0)
*foo = 1;