[cfe-dev] Pragma message in Clang?

Michael Spencer bigcheesegs at gmail.com
Sun Sep 26 23:33:34 PDT 2010


On Mon, Sep 27, 2010 at 2:24 AM, Matt Joiner <anacrolix at gmail.com> wrote:
> Perhaps, but #pragma message is hijacking the warning machinery,
> rather than generating a "note" as in GCC and MSVC. For code with many
> such messages, this would be irritating. If "message" isn't
> standardized however, I can understand your lack of interest in it.

I originally tried to emit a note, but I couldn't get clang to print
it. Implementing this was actually my first patch to clang, so I never
tried to figure out exactly how to get that working.

I'm all for changing this to a note as long as clang prints it without
any extra flags.

> Thanks everyone for your time!
>
> On Mon, Sep 27, 2010 at 2:03 PM, Chris Lattner <clattner at apple.com> wrote:
>>
>> On Sep 26, 2010, at 6:51 PM, Matt Joiner wrote:
>>
>>> Hi, patch works. However using pragma message will generate a warning traceback:
>>>
>>> data.c:447:1: warning: TODO: i need to do X
>>> TODO("i need to do X")
>>> ^
>>> In file included from data.c:1:
>>> In file included from ./data.h:2:
>>> In file included from ./types.h:3:
>>> ./utility.h:70:20: note: instantiated from:
>>> #define TODO(todo) MESSAGE("TODO: " todo)
>>>                   ^
>>> ./utility.h:68:22: note: instantiated from:
>>> #define MESSAGE(msg) MESSAGE2(message(msg))
>>>                     ^
>>> ./utility.h:67:25: note: instantiated from:
>>> #define MESSAGE2(pslit) _Pragma(#pslit)
>>>                        ^
>>> <scratch space>:237:2: note: instantiated from:
>>> message("TODO: " "i need to do X")
>>> ^
>>>
>>> Where GCC only generates a single line:
>>> data.c:447: note: #pragma message: TODO: i need to do X
>>
>> I think that this is a feature, not a bug.  Making all the diagnostics consistent is good for simplicity of the code.
>>
>> -Chris
>




More information about the cfe-dev mailing list