I have a header with a particular set of rules that the user must follow. If the user does not want to follow the rules, they must define a preprocessor macro which will disable the checks. If the user is using the library, the user must include the header in every one of their classes that uses any code from the library or explicitly state otherwise by the above mentioned preprocessor (in this case, the header may be included implicitly [using one of the library’s classes] which is fine):
// User using my library, they must include the BaseHeader.h or otherwise use the following define
// #define NOT_USING_BASE_HEADER //(can of course be defined project wide)
#include <BaseHeader.h>
// ... other includes (not necessarily from my library)
class Foo
{
//...
};
Is there a way to accomplish this? Keep in mind that the base header is also being included
I’m not sure if I understand your question entirely, but do you think this will help?
BaseHeader.h:
internal_header.h:
If you want to make it so that it doesn’t take “internal” includes of the baseheader.h, then you have to add/remove a define to make sure that it doesn’t define it:
internal_header.h:
And in BaseHeader.h:
Cheers,
Simon