<div dir="ltr"><div dir="ltr">This is a frequently asked question, and the solution is to use -frewrite-includes. We should consider adding it to <a href="http://clang.llvm.org/docs/FAQ.html">http://clang.llvm.org/docs/FAQ.html</a>.</div><div dir="ltr"><br></div><div>Basically, yes, clang's warnings look at macro definitions, so if you pre-process, you can expect to get different warnings. If you add -frewrite-includes, then clang should produce the same set of warnings when compiling the un-preprocessed source as the preprocessed source.</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Nov 7, 2018 at 11:39 PM Mikael Holmén via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I get this with a clang built from trunk, but also old clang versions <br>
behave like this.<br>
<br>
If I compile foo.c like this I get no warnings at all:<br>
<br>
clang -Wall -o foo.o -c foo.c<br>
<br>
But if I first preprocess it<br>
<br>
clang -Wall -o foo.pp.c -c foo.c -E<br>
<br>
and then compile the preprocessed output:<br>
<br>
clang -Wall -o foo.o -c foo.pp.c<br>
<br>
then clang warns:<br>
<br>
foo.c:7:12: warning: equality comparison with extraneous parentheses <br>
[-Wparentheses-equality]<br>
if (((i) == (j)))<br>
~~~~^~~~~~<br>
foo.c:7:12: note: remove extraneous parentheses around the comparison to <br>
silence this warning<br>
if (((i) == (j)))<br>
~ ^ ~<br>
foo.c:7:12: note: use '=' to turn this equality comparison into an <br>
assignment<br>
if (((i) == (j)))<br>
^~<br>
=<br>
1 warning generated.<br>
<br>
---<br>
<br>
Is this how it's supposed to be? Is it perhaps even a feature?<br>
<br>
It's not something I suffer from in any way, I just noticed it yesterday <br>
and thought it was odd since I thought compiling the original file or <br>
the preprocessed output would behave the same way.<br>
<br>
Regards,<br>
Mikael<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>