Reputation: 11479
I'm compiling a program using a library in C using clang. I want to check my program for errors (-Wall -Weverything
) but I don't want to check the library. Is there a way to restrict clang's warnings to just my source files?
Upvotes: 2
Views: 54
Reputation: 170055
If a library header file is generating copious amounts warnings whenever you include it, you can try and solve by using a bit of indirection (what else).
So for a library header named lib_a.h
, create a wrapper (my_lib_a.h
) that looks something like this:
#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Weverything"
#endif
#include "lib_a.h"
#ifdef __clang__
# pragma clang diagnostic pop
#endif
Now include it instead of directly including the library header.
Those pragams will turn off the warnings for that particular library header only.
You can of course add support for other tool-chains, and even make this utility header the point of entry for all the problematic headers in your program. Precompiling it will make the overhead negligible.
Upvotes: 2