I wanted to create weak alias for several functions so that I can declare it in a header file but then define it later on in different files. For some reason I still get a redefinition error from gcc.
Ideally for functions that don't have implementations I would like for it to default back on the alias.
I have tried removing alias("Default_Handler") and it seems to compile but it sort of destroys my intention for this application I am trying to write.
vector_table.h
void __attribute__((noreturn)) Default_Handler (void);
void NMI_Handler(void) __attribute__((weak, alias("Default_Handler")));
startup.c
#include "vector_table.h"
void Default_Handler(void){
for(;;);
}
void NMI_Handler(void){
for(;;);
}
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Wall -Wno-unused -Wextra -pedantic -H -g3 -gdwarf-2 -O0 -std=c90 -ffreestanding -c startup.c
startup.c:93:6: error: redefinition of 'NMI_Handler'
void NMI_Handler(void){
^
In file included from startup.c:3:0:
vector_table.h:17:6: note: previous definition of 'NMI_Handler' was here
void NMI_Handler(void) __attribute__((weak, alias("Default_Handler")));