<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jan 13, 2014 at 9:58 PM, Prathamesh Kulkarni <span dir="ltr"><<a href="mailto:bilbotheelffriend@gmail.com" target="_blank">bilbotheelffriend@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Tue, Jan 14, 2014 at 1:57 AM, Richard Trieu <<a href="mailto:rtrieu@google.com">rtrieu@google.com</a>> wrote:<br>

> Prathamesh,<br>
><br>
> Can you tell me more about your use case?  Is this a common pattern you have<br>
> encountered?<br>
</div>Um no, it's a contrived test case.<br></blockquote><div><br></div><div>Is this a reduction of a real problem? (This seems like a somewhat legitimate complaint either way -- a macro that gets undefined probably wasn't an include guard -- but if this actually occurs in the wild, it would make this a higher priority issue.)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
#ifndef Macro1<br>
#define Macro2<br>
Should warning be suppressed, if Macro2 gets undefined later in the<br>
same header ?<br>
eg:  (they are literally named Macro1 and Macro2)<br>
<div class="im">#ifndef Macro1<br>
#define Macro2<br>
...<br>
</div>#undef Macro2<br>
#endif<br>
<br>
Is it better to suppress the warning because it's equivalent to:<br>
#ifndef Macro1<br>
#endif<br>
<div class="im"><br>
><br>
> The header guard warning triggers on files with the following format:<br>
><br>
> // Start of file<br>
> #ifndef Macro1<br>
> #define Macro2<br>
> ...<br>
> #endif // matches the #ifndef on the first line.<br>
> // End of file<br>
><br>
> and warns when Macro1 and Macro2 are close, but not exactly the same.  The<br>
> warning already ignores cases where Macro1 and Macro2 are very different<br>
> (edit distance is over half the length).  A similar exemption maybe be<br>
> warranted in this case too.<br>
<br>
</div>Thanks for pointing that out. However that's not the issue.<br>
Could you please explain in short heuristics used by clang to decide<br>
when the two macros are<br>
"sufficiently" different ? Thanks ;)<br>
<br>
><br>
> Richard<br>
<div class="im HOEnZb">><br>
><br>
> On Mon, Jan 13, 2014 at 3:06 AM, Prathamesh Kulkarni<br>
> <<a href="mailto:bilbotheelffriend@gmail.com">bilbotheelffriend@gmail.com</a>> wrote:<br>
>><br>
</div><div class="HOEnZb"><div class="h5">>> For the following test-case:<br>
>> #ifndef FOO<br>
>> #define FOO2<br>
>><br>
>> #undef FOO2<br>
>> #endif<br>
>><br>
>> -Wheader-guard emits warning:<br>
>> ./foo.h:4:9: warning: 'FOO' is used as a header guard here, followed<br>
>> by #define of a different macro [-Wheader-guard]<br>
>> #ifndef FOO<br>
>>         ^~~<br>
>> ./foo.h:5:9: note: 'FOO2' is defined here; did you mean 'FOO'?<br>
>> #define FOO2<br>
>>         ^~~~<br>
>><br>
>> Is this appropriate or should it suppress warning in this case<br>
>> since it's equivalent to the following: ?<br>
>> #ifndef FOO<br>
>> #endif<br>
>><br>
>> Thanks and Regards,<br>
>> Prathamesh<br>
>> _______________________________________________<br>
>> cfe-dev mailing list<br>
>> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
><br>
><br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div></div>