A simple solution would be to to just declare it as follows:
static uint16 dummyVar = 0;
Question
I have a variable in an header file:
myHeader.h
uint16 dummyVar = 0;
extern const uint16 myVar __attribute__((weak,alias("dummyVar")));
So when I don't link the parts where myVar
gets defined, the linker will just give it the value of the symbol dummyVar
.
My problem is, that I am working on a Project with a given architecture, where my Header-File myHeader.h
is included by several C-Files. Because of that I get multiple definitions of dummyVar
. But when I define dummyVar
outside of my header it doesnt work anymore for my __attribute__
since dummyVar
needs to be defined when it is assigned as an alias.
Is there any way I can work around this without changing the basic architecture of this?
Solution
A simple solution would be to to just declare it as follows:
static uint16 dummyVar = 0;