I would like to use __weak
in a library I am creating, but I want to make sure it is compliant with a known "C-number" standard. Which standard introduced this? Or is it a non-standard compiler extension that most compilers have supported? (Either through the keyword or __attribute__
.)
EDIT: Probably should not have used the term "keyword", mostly interested if "weak" in some form is a standard?
CodePudding user response:
__weak
is not part of the C standard.
__weak
is a compiler extension specific to the compiler, for example available on Keil and COSMIC compiler. __attribute__
is a compiler extensions from gcc GNU C compiler, available for example on clang, TASKING Compiler, TI Arm Compiler, and so on. For example, __weak
is invalid on gcc.
You can browse STM32CubeF4/cmsis_compiler.h for some compiler-specific macros definitions for STM32Cube project for some compilers.
It is common, because of the popularity of ELF format, which has the support for weak symbols.