title: Using #ifdef in static libraries (C++, Eclipse CDT)
body: <p>i have a question regarding my project management in Eclipse CDT, programming in C++ and using GCC to compile. 
  Lets say I have a driver library for microcontroller-type A (driverA.hpp) and a driver library for microcontroller-type B (driverB.hpp) (peripherals etc.). In both libraries the function interfaces are the same. Furthermore I have libraries for certain devices like device X which should be usable for both controller types (example: deviceX.hpp). In a project (projectY) using those things, I will add the corresponding driver library (driverA.hpp or driverB.hpp) and I want to add a compiler flag in order to name the controller type I want to use.</p>
  
  <p>In deviceX.hpp, I want to make a distinction between the two types, so I thought of adding something likes this:</p>
  
  <pre><code>#ifdef CONTROLLER_A
    #include driverA.hpp
  #elseif CONTROLLER_B
    #include driverB.hpp
  #endif
  </code></pre>
  
  <p>This library will also be linked to projectY, in which I want to add a compiler flag like CONTROLLER_A and the library deviceX with the correct controller type will be linked.</p>
  
  <p>BUT, I know, that does not work. That's why I'm asking you: what is the best (or: the common) way to do such library dependencies? Adding the deviceX libary as Source Location? Or is there another way?</p>
  
  <p>Best Regards</p>