[cfe-dev] Pragma message in Clang?

Matt Joiner anacrolix at gmail.com
Sun Sep 26 18:51:37 PDT 2010


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

Here are the convoluted macros clang shows instantiation from:

#define MESSAGE2(pslit) _Pragma(#pslit)
#define MESSAGE(msg) MESSAGE2(message(msg))

#define TODO(todo) MESSAGE("TODO: " todo)

I love the text in test/Lexer/pragma-message.c, lots of fun.

On Mon, Sep 27, 2010 at 4:39 AM, Chris Lattner <clattner at apple.com> wrote:
>
> On Sep 26, 2010, at 10:30 AM, Michael Spencer wrote:
>
> What's Clang's equivalent to `#pragma message` as used in [GCC][1] and
>
> [MSVC][2]?
>
>  [1]: http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas
>
>  [2]: http://msdn.microsoft.com/en-us/library/x7dkzch2.aspx
>
>
>
> Patch attached. Please verify.
>
> - Michael Spencer
>
> Looks good to me, please commit.  Feel free to enable it by default in GNU
> mode also if it hasn't already been done.
> -Chris




More information about the cfe-dev mailing list