Why use the __ attribute __ ((weak)) and # pragma is weak?

I am reading the code to determine the interrupt vector for STM32 here . For some reason, both __attribute__((weak)), and are used #pragma weak:

void __attribute__((weak)) NMI_Handler(void); /* NMI Handler */ // [line 12]
#pragma weak NMI_Handler = Default_Handler    /* NMI handler */ // [line 48]

Somehow it seems that the use __attribute__((weak))and #pragma weakredundant.

Is it possible to do without one of them? Is this style standard?

+3
source share
1 answer

You are right, but ...

#pragma weak NMI_Handler = Default_Handler 

can independently do what is intended. But it would be nice to add __attribute__((weak))functions to the prototypes for the following reason -

, , . IDE/Editor NMI_Handler, __attribute__((weak)), NMI_Handler, , NMI_Handler - ! , __attribute__((weak)), , , , , / !

+2

All Articles