Is this correct action for the c compiler/preprocessor ??

Bill Crews bc at cyb-eng.UUCP
Thu Nov 7 12:56:58 AEST 1985


> The question was whether the C preprocessor should substitute for an
> occurrence of a macro formal within a string within the body of the
> macro...
>
> > Being able to insert literal text in strings is very useful.
> 
> The fact that a feature is "useful" is not sufficient argument that it is
> correct.
> 
>                                                the definition that most of
> us use these days (K&R) says one thing:
> 	Text inside a string or a character constant is not subject to
> 	replacement.
> ...which is pretty explicit, but the compiler that a lot of us use
> substitutes inside strings.  I would like to have an authoritative
> definition and a correct compiler in accord with the definition.
> -- 
> Dick Dunn

As I read K&R, one could define the following:

#define	COMMENT	/*
#define	TNEMMOC	*/

COMMENT
	This tells all about my great program.
TNEMMOC

Not that I would particularly WANT to, but it DOES seem like C compilers
should allow this kind of thing if K&R allows it.  It is interesting that
this kind of thing never came up as a problem so long as de facto standard
Unix compilers were used.  Only when a lot of people started writing compilers
to the K&R specification was it discovered (or considered significant) that
Unix compilers didn't always conform either.  My guess is that the weight of
experience with Unix compilers is greater than K&R's these days.
-- 
	- bc -

..!{seismo,topaz,gatech,nbires,ihnp4}!ut-sally!cyb-eng!bc  (512) 835-2266



More information about the Comp.lang.c mailing list