<div style="font-family: arial, helvetica, sans-serif"><font size="2">This already works like I would have implemented it (very conservatively so this warning is only generated if there is an explicit use of a member). I added a corresponding test in r<span style>159130.</span><br>
<br><div class="gmail_quote">On Thu, Jun 21, 2012 at 8:34 AM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="font-family:arial,helvetica,sans-serif"><font size="2"><div class="gmail_quote"><div><div class="h5">On Wed, Jun 20, 2012 at 11:33 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@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><div>On Wed, Jun 20, 2012 at 11:26 PM, Chandler Carruth <<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>> wrote:<br>


> On Wed, Jun 20, 2012 at 11:12 PM, Daniel Jasper <<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>> wrote:<br>
>><br>
>> I have looked into both suggestions, but I am not sure what the right<br>
>> thing is:<br>
>><br>
>> __attribute__((used)): According to the gcc docs, "this attribute,<br>
>> attached to a function, means that code must be emitted for the function<br>
>> even if it appears that the function is not referenced". It doesn't really<br>
>> say anything about silencing warnings and the code emitting part does not<br>
>> really apply to fields. I am happy to make this attribute silence the<br>
>> warning, but I don't know whether that makes sense.<br>
>><br>
>> -Wused-but-marked-unused: We run into trouble if certain field usages are<br>
>> only conditionally included (#ifdefs, ...).  In that case, it would be<br>
>> impossible to create source code that produces neither<br>
>> -Wused-but-marked-unused nor -Wunused-private-field if compiled in different<br>
>> modes.<br>
>><br>
>> Any thoughts?<br>
><br>
><br>
> I really should have thought of this when we chatted. It's quite verbose,<br>
> but it works:<br>
><br>
> struct S {<br>
>   int platform_specific_member<br>
> #ifdef __x86_64__<br>
>     __attribute__((unused))<br>
> #endif<br>
>     ;<br>
> };<br>
><br>
><br>
> We just have to make the attribute itself be conditioned on the same thing<br>
> as the use of the member. As long as this attribute never impacts semantics,<br>
> this should be fine. Do others thing this is too cumbersome?<br>
<br>
</div></div>If you're going to conditionally define its usage, why not just<br>
conditionally define the whole variable? (admittedly there are some<br>
cases where that might not work, but I'm not sure they're the cases<br>
we're dealing with)</blockquote><div><br></div></div></div><div>Certainly, that's another option.</div><div><br></div><div>But in many cases, ABI or other concerns prevent that. I should have used a better example: NDEBUG. </div>

</div></font></div>
</blockquote></div><br></font></div>