IT lexicon › Programming › Weak symbol

Weak symbol

Programming På svenska → Updated: 2026-11-03

A definition the linker uses only if no other, "strong" definition of the same name turns up.

GCC and Clang spell it __attribute__((weak)), and ELF supports it natively. Embedded code is a heavy user: CMSIS startup files define every interrupt handler as a weak alias for a Default_Handler that simply loops forever. Write your own USART1_IRQHandler and it wins; write none and the interrupt lands in the loop instead of the link failing.

The flip side is that a typo — USART1_IRQhandler — or a forgotten extern "C" in C++ compiles without a peep. The program then hangs in Default_Handler the first time the interrupt fires, which makes for one of the more baffling debugging sessions the trade has to offer.

← Back to the lexicon