Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Library headers and #define

Tags:

I wasn't sure what to search for for this one. So excuse me if this is simple. But let me outline the scenario and see what answers are out there.

Let's say I have a library which defines a structure like this:

struct Example {
    int a;
#if B_ENABLED
    int b;
#endif
};

This header gets installed as a part of the library's installation as a whole. My question here is that if my library defines B_ENABLED it will have a structure with these two variables included. However if my application does not define this as well. Then it will interpret the header as defining a struct with only one member.

Is the best way to handle this just to generate some kind of "options" header which would include all of the #defines that were specified in the library build?

My library builds with CMAKE. So a CMAKE solution for this is extra credit =D.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!