Comemnts are white space (was re: #define THING -10)

Stan Brown browns at iccgcc.decnet.ab.com
Tue Feb 5 04:55:07 AEST 1991


In article <12924 at wraxall.inmos.co.uk>, nathan at elberton.inmos.co.uk (Nathan Sidwell) writes:
> Well gcc -ansi doesn't, 
> source is
> 
> #define NUM -10
> main()
> {
>   int x;
>   x = x-NUM;
>   x = 1/**/2;
> }
> 
> preprocessor output is
> 
> main()
> {
>   int x;
>   x = x--10;
>   x = 1 2;
> }
> 
> which fails, note that it is partly correct as
> the /**/ has been reduced to a space. This is gcc 1.36, has it been
> fixed in later versions?

Comments are _supposed_ to reduce to spaces in ANSI C.  There's no error
to 'fix'.

Standard pg 19 lines 37 ff (sec 3.1):  "Preprocessing tokens can be
separated by _white space_; this consists of comments (described later),
or _white-space characters_ (space, horizontal tab, new-line, vertical
tab, and form-feed), or both."

Standard pg 6 lines 31 ff (sec 2.1.1.2, Translation Phases): "The source
file is decomposed into preprocessing tokens and sequences of
white-space characters (including comments)."

Hey--this is all my opinion, nobody else's. Rely on it at your peril.
                                   email: browns at iccgcc.decnet.ab.com
Stan Brown, Oak Road Systems, Cleveland, Ohio, USA    +1 216 371 0043



More information about the Comp.lang.c mailing list