user7329: I have a library that uses conditional compilation based on the preprocessor variables. The library is a separate .cpp object file with a header file.
How can I pass preprocessor variables to the compilation of the library? Standard #define in a sketch file wouldn't work, since their life will be limited to my sketch object file(s), not the library's.
Normally it is solved by the ./configure script and/or the custom make process. How can I do it on Arduino?
Supplying a separate compilation/source code of the library for all 2^8 combinations of the preprocessor switches doesn't seem feasible...

user4143: There's two basic methods:

Provide a config.h file with the options in that the user modifies
Place the options on the command line with -D

A decent IDE allows you to modify the compilation command line to add options.
My IDE, UECIDE, allows the creation of menu entries that set library options.

user18478: The problem here is that the Arduino IDE is not setup for doing this. Any real IDE has the possibility to set defines.  
If you want your library to be used by arduino IDE users you will have to go to dirty routes like the #include and config.h approach already mentioned.
If I'm not mistaken arduino IDE compiles libraries with the full include path so you can have the config.h next to your sketch.ino file.
If the library is not intended for arduino IDE users I would advice using a real IDE like my Arduino Eclipse Plugin.  

7329: <p>I have a library that uses conditional compilation based on the preprocessor variables. The library is a separate <code>.cpp</code> object file with a header file.</p>
<p>How can I pass preprocessor variables to the compilation of the library? Standard <code>#define</code> in a sketch file wouldn't work, since their life will be limited to my sketch object file(s), not the library's.</p>
<p>Normally it is solved by the <code>./configure</code> script and/or the custom make process. How can I do it on Arduino?</p>
<p>Supplying a separate compilation/source code of the library for all 2^8 combinations of the preprocessor switches doesn't seem feasible...</p>
 4143: <p>There's two basic methods:</p>

<ol>
<li>Provide a config.h file with the options in that the user modifies</li>
<li>Place the options on the command line with -D</li>
</ol>

<p>A decent IDE allows you to modify the compilation command line to add options.</p>

<p>My IDE, UECIDE, allows the creation of menu entries that set library options.</p>
 18478: <p>The problem here is that the Arduino IDE is not setup for doing this. Any real IDE has the possibility to set defines.  </p>

<p>If you want your library to be used by arduino IDE users you will have to go to dirty routes like the #include and config.h approach already mentioned.
If I'm not mistaken arduino IDE compiles libraries with the full include path so you can have the config.h next to your sketch.ino file.</p>

<p>If the library is not intended for arduino IDE users I would advice using a real IDE like my Arduino Eclipse Plugin.  </p>
