[Python-Dev] Re: [Python-checkins] python/dist/src
configure,1.279.6.17,1.279.6.18 configure.in,1.288.6.17,1.288.6.18
Tim Peters
tim.one@comcast.net
Wed, 26 Feb 2003 00:51:07 -0500
[Neal Norwitz]
> I always thought you could have whitespace between the '#' and the
> directive name, but not before the '#'. According to everything I
> read, you can have spaces before the '#', tabs are less clear. I
> didn't find any info about which standard they are referring to.
The C standards aren't available for free, but the C99 standard is cheap.
It's quite clear.
A preprocessing directive consists of a sequence of preprocessing
tokens that begins with a # preprocessing token that (at the start
of translation phase 4) is either the first character in the source
file (optionally after white space containing no new-line
characters) or that follows white space containing at least one
new-line character, and is ended by the next new-line character.
A new-line character ends the preprocessing directive even if it
occurs within what would otherwise be an invocation of a function-
like macro.
Later:
The only white-space characters that shall appear between
preprocessing tokens within a preprocessing directive (from just
after the introducing # preprocessing token through just before
the terminating new-line character) are space and horizontal-tab
(including spaces that have replaced comments or possibly other
white-space characters in translation phase 3).
So you can actually have any whitespace characters before the #, but only
space and tab after it.
I used to have a bootleg C89 standard on my drive, but can't seem to find
it. I doubt it's different here, but don't know for sure. The C99
Rationale (not part of the C99 standard) says:
Different implementations have had different notions about whether
white space is permissible before and/or after the # signalling a
preprocessor line. The C89 Committee decided to allow any white space
before the #, and horizontal white space (spaces or tabs) between
the # and the directive, since the white space introduces no
ambiguity, causes no particular processing problems, and allows
maximum flexibility in coding style. Note that similar
considerations apply for comments, which are reduced to white space
early in the phases of translation.
This strongly implies that the same rules held in C89.