I have a library project with a inline function in my Lib.h
:
static inline void DoStuff(void) __attribute__ ((always_inline));
static inline void DoStuff(void)
{
#if(SYMBOL == 1)
// Stuff
#elif(SYMBOL == 2)
// Other stuff
#endif
}
I compile my library into libLib.a
and set SYMBOL=2
. Now I use this library and the header Lib.h
in some other project. This project set SYMBOL=1
and calls DoStuff()
in this project. Which part of the #if
directive gets executed? I assume that the compiler will run the part with #if(SYMBOL == 1)
but I´m not sure. How does the compiler handle it?