pre processing question

Hello,

I write a big library used by 3 differents sketch.

In each sketch, I use preprocessing #define XYZ variable.

In the library I test the presence of the variable to reduce the size of the generated code.

But, unfortunately, this technique doesn’t work.

The pre processor doesn’t see preprocessing variable declared in the sketch.

So, every time all of the library is compiled and the generated code is too large.

Any workaround for this problem ?

Best regards and thanks for your help.

Thierry

The libraries are compiled separately. Thus they won't see the defines in your main sketch.

Thanks for your response, Is that any issue to have conditional compiling to reduce the size of the generated code ?

My project is: 1) Software to do the parametrization of the EEPROM part. 2) Software to test the platform. 3) Real time software.

All 3 project share the same library.

For example, the real time software have no connection to the console, so all Serial.print have to be removed. (that also spare memories).

Because the setup of the hardware is the same for all 3 projects, i wrote the initialization in the the library, but if the project is "test platform", I will have some debug info on the console.

If the library is compiled entirely, the size is too large for the capacity of the microcontroller...

Best regards and many thanks for your help.

Thierry

The linker drops any functions/methods which are not called. So even if you could get your #define going your code would still be to big.

Mark