Topic: Re:backslash
Author: jla@to.icl.fi (Jari Laaksonen)
Date: 1995/06/29 Raw View
In message <3srtt4$247@engnews2.Eng.Sun.COM> - clamage@Eng.Sun.COM (Steve
Clamage) writes:
> In article 36k@louhi.to.icl.fi, jla@to.icl.fi (Jari Laaksonen) writes:
> >What is your interpretation of the ARM chapter 16.1 "Phases of Preprocessing"
> >where is said that "Each pair of a backslash character \ immediately followed
> >by a new-line is deleted, with the effect that the next source line is
> >appendedto the line that contained the sequence."
> You are correct that "immediately" here means "with no intervening
> characters, blank or not".
>
> The draft standard has slightly different wording but the same meaning.
> The rule is the same as in the C standard.
>
> It sounds like you are saying that two compilers treat the sequence
> <backslash> <blank> <newline>
> as if the <blank> were not present, and splice the two physical lines
> into one logical line. If that is the case, they are probably wrong to
> do so.
I just checked this with Visual C++ 1.52 and it seems that it follows
ARM better here.
Example:
// comment line 1 \<newline>
comment line 2
// comment line 3\<blank><newline>
comment line 4
char s1[] = "a\<newline>
b\<newline>
c";
char s2[] = "a\<blank><newline>
b\<newline>
c";
After preprocessing (cl -P x.cpp) this becomes to:
comment line 4
char s1[] = "a\<newline>
b\<newline>
c";
char s2[] = "a\<blank><newline>
<newline>
bc";
> But I suppose a compiler could treat backslash followed by blanks and tabs
> up to a newline the same as backslash-newline, as an extension. It won't
> break any well-formed programs, and it avoids mysterious error messages
> caused by invisible trailing blanks on a line.
I'm asking this because I'm writing two little utilities, one for
stripping comments out of source code and the other for converting
C++ comments to C comments. If two out of three "major" C++ compilers
are "broken", I'm not sure what I should do...
// Albert
(Team OS/2)
email: jla@to.icl.fi
-----------=======================================
Author: rad6938@gemini.tntech.edu (Rad)
Date: 1995/06/30 Raw View
In message <3srtt4$247@engnews2.Eng.Sun.COM> - clamage@Eng.Sun.COM (Steve
Clamage) writes:
> In article 36k@louhi.to.icl.fi, jla@to.icl.fi (Jari Laaksonen) writes:
> >What is your interpretation of the ARM chapter 16.1 "Phases of Preprocessing"
> >where is said that "Each pair of a backslash character \ immediately followed
> >by a new-line is deleted, with the effect that the next source line is
> >appendedto the line that contained the sequence."
> You are correct that "immediately" here means "with no intervening
> characters, blank or not".
>
> The draft standard has slightly different wording but the same meaning.
> The rule is the same as in the C standard.
>
> It sounds like you are saying that two compilers treat the sequence
> <backslash> <blank> <newline>
> as if the <blank> were not present, and splice the two physical lines
> into one logical line. If that is the case, they are probably wrong to
> do so.
Hmmmm, I think within string or character literals the backslash followed by a
space would be undefined or implementation-defined behavior so perhaps
line-concatenation is valid (for the compilers) in that context? I don't see
anyway to justify concatentation in comments though.
----------------------------------------------------------------------------
Richard Deken Graduate student in electrical engineering
PGP public key available Tennessee Technological University
Internet: rad6938@gemini.tntech.edu Cookeville, TN, USA