The Preprocessor and tokens

Doug Gwyn gwyn at smoke.brl.mil
Thu Mar 28 08:15:20 AEST 1991


In article <1991Mar27.033525.21697 at tkou02.enet.dec.com> diamond at jit345.enet@tkou02.enet.dec.com (Norman Diamond) writes:
>>what does the Standard say about constuctions like these:
>>#define _	+ 42
>>int j = 6_;
>>#define N	42
>>int k = 0x7e+N;
>>Do K&R compilers do it any differently?
>Usually.  The standard broke some working, valid, code this time.

I've commented before about how sick I get of hearing people pontificate
over how "ANSI C breaks valid code".  In fact, the standard UNIX (Reiser)
preprocessor produces

	int j = 6_;

	int k = 0x7e+42;

for the example in question, which half does "what was wanted" and half
does NOT do "what was wanted".  It is this sort of inconsistent existing
practice that gave X3J11 the latitude to decide on the behavior specified
in the C standard.  Many alternative proposals were offered, including
several from members of the public during the public review process, but
ALL of them were technically flawed.  Given the difficulty of "getting it
right" during preprocessing, X3J11 opted to defer "getting it right" to a
later phase of translation.  Anyone using a decent coding style should
encounter no problems.  The only serious trap to watch out for is the
second example, which is avoidable by using whitespace around operators.
The first example is stupid anyway.



More information about the Comp.std.c mailing list