<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>On Apr 13, 2014, at 1:29 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Apr 13, 2014 at 12:38 PM, Kyle Sluder <span dir="ltr"><<a href="mailto:kyle@ksluder.com" target="_blank">kyle@ksluder.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="">On Apr 12, 2014, at 2:34 AM, David Chisnall <<a href="mailto:David.Chisnall@cl.cam.ac.uk">David.Chisnall@cl.cam.ac.uk</a>> wrote:<br>

><br>
> For _Error, you can use C11's _Static_assert():<br>
><br>
> #define fail(msg) _Static_assert(0, msg)<br>
><br>
> There's no standard equivalent for #warning, unfortunately.<br>
<br>
</div>That workaround is sufficient for my use case, but the output is noisy and as you note it doesn’t work for those who treat warning differently from errors.<br>
<br>
So, can anyone opine on whether such a patch would be accepted?</blockquote><div><br></div><div>I don't think we want _Warning and _Error. You can use #pragma message to emit a warning (as _Pragma("message \"...\"") within your macro).</div></div></div></div></div></blockquote><div><br></div><div>Such a macro definition is sadly impossible because the C99 spec is too strict: _Pragma only accepts a single string literal. No implicit concatenation of string literals is allowed.</div><div><br></div><div>If the clang folks are fine with relaxing that, then _Pragma becomes sufficient for my purposes. But I presume it was so strictly defined in the spec for some reason.</div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>I'd much prefer to add support for something like '#pragma clang error "blah"' rather than adding something like _Error(...), if _Static_assert is somehow insufficient, but I'd like to understand what's wrong with _Static_assert first.</div>
</div></div></div>
</div></blockquote><br><div>Well, for starters, it can’t be used to produce a warning. That alone makes it worth contemplating alternatives, in my view.</div><div><br></div><div>But even for the error-producing use case, the error output contains a lot of noise about failing nonsensical assertion conditions. The best thing about #error and #warning is that I get to control the output, and that lets me match clang’s much-lauded user-friendliness in my own error messages.</div><div><br></div><div>--Kyle Sluder</div></body></html>