I'm turning into a standards geek. Shoot me now.
"Ben Wing" <ben(a)666.com> wrote:
> -----Original Message-----
> From: Vin Shelton [mailto:acsï¼ xemacs.org]
> Sent: Wednesday, January 26, 2005 7:35 PM
> To: Ben Wing
> Cc: xemacs-patches(a)xemacs.org; 'Dr. Volker Zell'
> Subject: Re: [AC21.4] sheap.c printf string patch for
> gcc-3.3.3 on Cygwin
>
>
> "Ben Wing" <ben(a)666.com> writes:
>
>
> >> APPROVE COMMIT 21.4
> >>
> >> I actually committed the James variation of the patch. Patch
> >> will appear in XEmacs 21.4.17, "Jumbo Shrimp".
> >>
> >> - Vin
> >>
> >
> > Vin -- it would be better to commit the version that I
> sent, not the
> > version that you have currently. Using multiple "" strings is the
> > ANSI-correct way to do things.
>
> I disagree - the patch I committed is perfectly valid and
> could potentially be accepted by more compilers.
Only if they are non-ANSI, which we don't support. In the past we've had
problems with compilers choking on long strings with embedded backslashes,
so "potentially" it could go the other way as well.
Do you happen to remember which compilers had trouble with this
construct? I don't know that it really matters, since we certainly want
to avoid constructs that trigger compiler bugs when can reasonably do
so. I'm just curious.
As far as ANSI goes, though, section 5.1.1.2 of the draft standard [1]
(I'm too cheap to buy the final version) says that the preprocessor is
to delete every backslash-newline pair before the compiler proper even
sees the code. Also, the C99 Rationale [2] in section 6.4.5, String
literals (page 55), says:
A string can be continued across multiple lines by using the
backslash-newline line continuation, but this requires that the
continuation of the string start in the first position of the next
line. To permit more flexible layout, and to solve some preprocessing
problems (see paragraph 6.10.3), the C89 Committee introduced string
literal concatenation. Two string literals in a row are pasted
together, with no null character in the middle, to make one combined
string literal. This addition to the C language allows a programmer
to extend a string literal beyond the end of a physical line without
having to use the backslash-newline mechanism and thereby destroying
the indentation scheme of the program.
So string pasting is the preferred method, but backslash-newline is also
allowed by the standard (along with its drawbacks). Since I'm the
trouble-maker that suggested backslash-newline in the first place, let
me say that I've changed my mind. Vin, we ought to do it Ben's way.
Footnotes:
[1]
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n843.htm
[2]
http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf
--
Jerry James
http://www.ittc.ku.edu/~james/