[comp.lang.c] comments before preprocessor directives

haahr@phoenix.Princeton.EDU (Paul Gluckauf Haahr) (05/13/88)

what is an ansi compliant c preprocessor supposed to do with

	#/*foo*/define	x y
	x

or

	/*foo*/#define	x y
	x

the preprocessor that is shipped with sun os 3.5 gives y for the first
case and x for the second.  i would assume this is probably the same
behavior as most reiser-derived preprocessors, which probably accounts
for the bulk of unix preprocessors.  how do other machines handle it
now?

and has anyone ever used code like that for a good reason?  has anyone
even seen any code which counts on one or the other behavior?

paul haahr
princeton!haahr (haahr@princeton.edu)

henry@utzoo.uucp (Henry Spencer) (05/16/88)

> what is an ansi compliant c preprocessor supposed to do with
> 	#/*foo*/define	x y
> or
> 	/*foo*/#define	x y

X3J11 sayeth that comments vanish (more precisely, turn into a single space)
before preprocessor directives are even thought about.  Also that white space
may occur before or after the #.  So the two examples above are equivalent
and define x to be y.
-- 
NASA is to spaceflight as            |  Henry Spencer @ U of Toronto Zoology
the Post Office is to mail.          | {ihnp4,decvax,uunet!mnetor}!utzoo!henry