[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

Neal Norwitz neal@metaslash.com
Tue, 25 Feb 2003 16:16:46 -0500


On Sun, Feb 23, 2003 at 10:29:59PM -0500, Tim Peters wrote:
> [from a checkin comment]
> > Need to make sure that preprocessor directives start in first column.
> > This means we can't indent code which has preprocessor directives,
> > nor have a space between [ #include for example.
> 
> [Neil Schemenauer]
> > What does the C standard say about this?  I'm curious.
> 
> Spaces and horizontal tabs are fine before '#', and between '#' and the
> directive name; other kinds of whitespace are not OK in directive lines (and
> directive lines are special this way); sounds like we're catering to a
> broken compiler here.

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.

I've found some different answers:

        http://www.opus1.com/vmsdoc/progtool/cpqc64/5492p033.htm

states:
        The ANSI C Standard removes the VAX C restriction that
        requires the # character introducing a preprocessor directive
        to always appear in column 1 of the source line. In Compaq C,
        white space and comments can now precede the # on the same
        line.

This:
        http://nimbus.pa.uky.edu/cfromfortran/preprocessor.htm
states:
        All preprocessor directives begin with # as the very first
        non-space character.  This is important - the first non-space
        character must be #, tabs will work with some implementations,
        but are not ANSI-compliant and will fail with others.  Spaces
        can appear before the # in ANSI C.

Neal