Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22014

Preprocessor symbol in library and change the symbols value while using the library

$
0
0

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?


Viewing all articles
Browse latest Browse all 22014

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>