Hi,
I need to do an assertion based on two related macro preprocessor #define
's declared in different header files... The codebase is huge and it would be nice if I could find a place to put the assertion where the two headers are already included, to avoid polluting namespaces unnecessarily.
Checking just that a file includes both explicitly might not suffice, as one (or both) of them might be included in an upper level of a nesting include's hierarchy.
I know it wouldn't be too hard to write an script to check that, but if there's already a tool that does the job, the better.
Example:
file foo.h
#define FOO 0xf
file bar.h
#define BAR 0x1e
I need to put somewhere (it doesn't matter a lot where) something like this:
#if (2*FOO) != BAR
#error "foo is not twice bar"
#endif
Yes, I know the example is silly, as they could be replaced so one is derived from the other, but let's say that the includes can be generated from different places not under my control and I just need to check that they match at compile time... And I don't want to just add one include after the other, as it might conflict with previous code that I haven't written, so that's why I would like to find a file where both are already present.
In brief: how can I find a file that includes (direct or indirectly) two other files?
Thanks!