[cfe-dev] [clang] How to ignore compiler warnings from macros in system headers?

Carlos Galvez via cfe-dev cfe-dev at lists.llvm.org
Sun Dec 26 14:28:48 PST 2021


Hi!

I've asked this question in StackOverflow
<https://stackoverflow.com/questions/70488470/how-to-ignore-compiler-warnings-for-macros-defined-in-third-party-headers>
without much success so I thought I'd come closer to the source and ask
here.

My use case is simple: ignore compiler warnings from 3rd-party headers that
I have no control over. The standard approach for this is simple - include
them as "system headers" via "-isystem". That works pretty well, except for
one bit - *macros*. Clang (and GCC) will still report warnings if I use
problematic macros each time I use them in my code. Why is that? Clang
knows where the macro comes from, shouldn't it be able to ignore the
warning? Is there a good way to achieve what I want, without using pragmas
or re-creating the third-party code myself?

Thanks!
/Carlos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20211226/27f015e7/attachment.html>


More information about the cfe-dev mailing list