[LLVMbugs] [Bug 17625] Precompiler Error "##"
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Oct 19 11:56:30 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=17625
jonathan.sauer at gmx.de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |jonathan.sauer at gmx.de
Resolution|--- |INVALID
--- Comment #1 from jonathan.sauer at gmx.de ---
I get with clang r192574 on Mac OS X:
% ~/LLVM/build/Release+Asserts/bin/clang -c clang.c clang.c:9:3: error: pasting
formed '"Hello""World"', an invalid preprocessing token
TESTDEFINE2("Hello", "World");
^
clang.c:4:41: note: expanded from macro 'TESTDEFINE2'
#define TESTDEFINE2(a,b) printf("%s", a ## b)
^
1 error generated.
I think that clang's behavior is correct, as per C11 §6.10.3.3p3 the result of
the token pasting operator ## must be a valid preprocessing token or the
behavior is undefined; and while a single string literal is a valid
preprocessing token (as defined in §6.4p3), two string literals are not (they
would be if they were *two separate* tokens, but ## produces a *single* token).
If you are coming from Visual C, this might help you:
http://stackoverflow.com/questions/1206624/differences-in-macro-concatenation-operator-between-visual-c-and-gcc
To get the code to work with clang, simply remove the "##", as string literals
next to each other will automatically be concatenated.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131019/355a558d/attachment.html>
More information about the llvm-bugs
mailing list