It's hard to describe in general terms so I'll use an example:
In a library I have a buffer. Its size should be the same as the width of the lcd. I have in the .h file:
#define phi_prompt_max_item_display_length 20
In the .cpp file:
If someone uses a 40x2 LCD, I want to define phi_prompt_max_item_display_length as 40. I want the arduino sketch to be able to override the define in .h
I tried this in .h:
#ifndef phi_prompt_max_item_display_length ///< Only define this if it has not been defined.
#define phi_prompt_max_item_display_length 20 ///< The render_list uses a buffer to render list item. 20 works for up to 20x4 displays to save SRAM.
I then have in arduino sketch #define phi_prompt_max_item_display_length 40 before it includes the .h
I get 40 in arduino sketch but I still get 20 in the library.
So are the define spaces separate between different .cpp files? How to do what I want to do? Thank you!