The Preprocessor and tokens

Blair P. Houghton bhoughto at pima.intel.com
Mon Mar 25 16:33:50 AEST 1991


In article <3137 at wyse.wyse.com> cmills at wyse.wyse.com () writes:
>Whilst composing this year's entry for the IOCCC, I stumbled on some
>ANSI wierdness and I was wondering, what does the Standard say about
>constuctions like these:
>
>#define _	+ 42
>
>int j = 6_;
>
>#define N	42
>
>int k = 0x7e+N;

The standard calls these things (`6_' and `0x7e+N')
"preprocessing numbers" and says they don't have to
be tokenized any further than that.

>My compiler refuses to exapnd the macros in these cases.

As it should; the macros aren't invoked.

>Is there a good
>reason for this (other than the preprocessor is a little easier to write
>if you define [0-9][0-9a-zA-Z_]* as a token)?

You forgot [+-.], which can also appear anywhere
after the leading digit.

Nope.  The rationale says the committee punted, claiming
that they didn't want to "burden" the preprocessor (uh, yeah...).

The last sentence of the paragraph in the rationale is,
"[in this case,] exercise of reasonable precaution in coding
style avoids surprises."

You can't BUY irony like that.

				--Blair
				  "If you think the IOCCC is a
				   mess, try reading X3.159-1989,
				   sometime..."



More information about the Comp.std.c mailing list