[cfe-dev] #error and #warning: why include "#error/#warning" in the diagnostic?

Ted Kremenek kremenek at apple.com
Tue Jan 31 22:25:31 PST 2012

On Jan 31, 2012, at 8:21 PM, Douglas Gregor wrote:

>> It seems nice to distinguish in the text where the actual text comes from. That said, it just seems nice-to-have, not super important.
>> Certainly "#error" seems like a pretty lame way to do this. ;] My initial thought would be:
>> foo.cc:42:13: error: (from source directive) this code requires widget to be defined
>> or some variant thereof.

That seems even more verbose, and not any more clearer.

>> Among other nice things is that then the message is the same between #error and #warning, and only the level changes. The downside I see is that it's more verbose.
> That's a step up from "#error", but I still find it unnecessary.

We can always support another command line flag that causes us to omit the '#error' and the '#warning' in the message for clients that don't want it (which do exist) since they can use diagnostic categories.  That may seem like overkill, but we have plenty of driver flags for controlling the behavior of diagnostics.  The suggestion of having "from source directive" is just a poor man's replacement of not having good diagnostic categories on the command line (where they make less sense).

I'm fine with keeping "#error" for the text diagnostics.  People are use to them, and the alternatives aren't necessarily any better.  We also don't have -W flags for errors anyway, so -Wdirective doesn't work.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120131/6774b14e/attachment.html>

More information about the cfe-dev mailing list