Question on backslash in string in define

Brian Matthews 6sigma2 at polari.UUCP
Tue Sep 11 10:31:45 AEST 1990


In article <1990Sep9.224807.17776 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
|In article <2480 at polari.UUCP> 6sigma2 at polari.UUCP (Brian Matthews) writes:
|>#define STR "12\
|>34"
|>char *x = STR;
|It is perfectly well defined.  The backslash-newline sequence vanishes
|completely before anything else is done.  x points to "1234".

Yep.  I thought that was the case, but I couldn't find it anywhere in
the standard.  I didn't think of looking in the translation phase
section, where it's spelled out very clearly.  Sigh.

Anyways, just for everyone's information, the Microsoft C compiler
that comes with SCO's version of Unix botches this.  It appears to
escape the first character of the next line (so in fact, my question
wasn't even correct.)

Thus,
#define STR "1\
\n2\n"

defines STR as "1\\n2\n", where it should define it as "1\n2\n"

Another of the vast array of reasons to avoid Microsoft C...
-- 
Brian L. Matthews	blm at 6sceng.UUCP



More information about the Comp.std.c mailing list