This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Preprocessor Problem?


Neil Booth <NeilB@earthling.net> writes:

> Even better, soon (not quite in the snapshots yet) the preprocessor
> will warn if it encounters a backslash separated by whitespace from
> any of the 4 newline possibilities.

Or perhaps we should just silently ignore spaces between a backslash
and end-of-line.  That is non-traditional, but it is the only sensible
behavior, and I'm quite sure it is compatible with relevant C
standards.  In fact, it is the only clean behavior for "text files" as
opposed to "binary files".  A "text file" does not have semantic
meaning that depends on end-of-line conventions or other non-visible
characters.  Making the number of spaces at the end of a line be
signifigant means you can't represent your programs on punch cards, or
other fixed-line-length file formats, or (more importantly these days)
on printed output.  (I.e. you can't print out a C program and scan it
back in again.)

Inside a quoted string, we need to warn about any non-standard line
terminators (including cr-nl or backslash-space-nl), since the correct
behavior may be surprising and what ends up in the actual string may
not be what the programmer expects; elsewhere, there is no real need to
warn about backslash-space-nl, except to warn about something many
compilers get wrong.

(I'm satisfied that the compiler will now warn about backslash-space-nl
- but in such a case, it is more correct to ignore the space than to
ignore the backslash!)
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]