[cfe-dev] Clang macro expansion differs from GCC

David Peixotto dmp at rice.edu
Thu Apr 8 08:34:09 PDT 2010

I have found a discrepancy in behavior between the clang preprocessor and gcc. 

$ cat t.c 
#define X 0 .. 1

0 .. 1 // Ok
X      // Bad: space between ..

$ gcc -E t.c 

0 .. 1
0 .. 1

$ clang -E t.c 

0 .. 1
0 . . 1

The problem is that when ".." is in the macro and the macro gets expanded, it adds a space between the dots. As you can see, the space is not added when the ".." is entered directly in the text. GCC does not insert a space in either case. 

I'm not sure this qualifies as a bug, but the reason I need this to work is that I am trying to compile GHC (a Haskell compiler) with clang. It uses GCC to preprocess c-- files (http://www.cminusminus.org) before parsing them and ".." is a valid operator in c--. Adding the extra space messes up the subsequent parsing phase.

I'd be happy to take a look at fixing this myself if someone could point me in the right direction.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100408/0ea310a0/attachment.html>

More information about the cfe-dev mailing list