David Sveningsson wrote:
The questions are:
a.) What's even going on here? Why the apparent inconsistency?
b.) What _should_ be the correct behavior, both in terms of the
(extended) GNU C language, and also the standard C language?
I believe that each c-style string must be encapsulated with " even for
the preprocessor to work. Actually, at least gcc-4.3 emits warnings
about missing termination for both line 1 and 2 in your test case.
Perhaps you could work something out with the ## concatenation operator?
Thanks for your replies.
So, double quotes are needed, but I'm still wondering why these behave
differently:
$ gcc -Wall -E test.c
$ gcc -Wall -c test.c
I mean, what does the gcc back end do _differently_ for those two commands?
---------------------------------------
As a side note, I just checked Torvalds' sparse compiler, and
interestingly, it returns:
test.c:2:1: warning: Newline in string or character constant
char * c = "llll\n#define y " y ;
In other words, it is amalgamating lines 1+2 into a single string
literal. However, sparse does this consistently, regardless of of
whether I use sparse -E or sparse -c. So, I can understand what it's doing.
Reza.