<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Apr 8, 2010, at 8:34 AM, David Peixotto wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I have found a discrepancy in behavior between the clang preprocessor and gcc. <br><br>$ cat t.c <br>#define X 0 .. 1<br><br>0 .. 1 // Ok<br>X      // Bad: space between ..<br><br>$ gcc -E t.c <br><snip><br><br>0 .. 1<br>0 .. 1<br><br>$ clang -E t.c <br><snip><br><br>0 .. 1<br>0 . . 1<br><br>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. <br><br>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 (<a href="http://www.cminusminus.org/">http://www.cminusminus.org</a>) before parsing them and ".." is a valid operator in c--. Adding the extra space messes up the subsequent parsing phase.<br></div></blockquote><div><br></div>Hi David,</div><div><br></div><div>I'm not particularly interested in fixing this: people abusing the C preprocessor to preprocess things that aren't C don't get much sympathy from me.  However, if you are able to produce a patch that works, doesn't break anything else, and doesn't affect performance, I'd be happy to apply it.</div><div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br>I'd be happy to take a look at fixing this myself if someone could point me in the right direction.<br></div></blockquote></div><div><br></div>lib/Frontend/PrintPreprocessedOutput.cpp is the code that outputs a .i file, the "<span class="Apple-style-span" style="font-family: Inconsolata; font-size: 12px; ">AvoidConcat" stuff is what you want.  It is what decides to add spaces to prevent three . tokens from looking like a ... for example.</span><div><font class="Apple-style-span" face="Inconsolata"><br></font></div><div><span class="Apple-style-span" style="font-size: 12px; "></span><font class="Apple-style-span" face="Inconsolata">-Chris<br></font><div><br></div></div></body></html>