A Deficiency of the C Preprocessor

Chris Torek chris at mimsy.UUCP
Sun Dec 21 05:36:39 AEST 1986


>In article <1259 at kontron.UUCP> cramer at kontron.UUCP (Clayton Cramer) writes:
>>I've got a complaint about the C preprocessor -- I doesn't support a
>>repetition for initializing data structures.

Why is this a complaint about the preprocessor?  The preprocessor
knows nothing about data structures.  (I do think it might be neat
to have loop constructs in the preprocessor.  E.g., to unroll a
loop, instead of writing

	*p++ = 0; *p++ = 1; *p++ = 2; *p++ = 3;
	*p++ = 4; *p++ = 5; *p++ = 6; *p++ = 7;

one could write

	#for (i = 0; i < 8; i++) {
		*p++ = i;
	#}

A fully programmable preprocessor would at least make a fun toy. :-)
[Of course, you can always write your own preprocessor.])

In article <1888 at batcomputer.tn.cornell.edu>
braner at batcomputer.tn.cornell.edu (braner) writes:
>I would like, if not that, at least an acceptance by the preprocessor
>of more parameters than required.

I find this even more confusing.  The only `parameters' in the
preprocessor are those given to macros.  A preprocessor that silently
ignored extra arguments to a macro would be quite annoying.

>As for compile vs. run time initialization of arrays:  A compiler I
>use creates code for all the initializations in the program ...
>Even worse, when an array is initialized, this compiler generates a line
>of code to initialize each entry, rather than an image of the array and
>looping code.

That sounds like a pretty poor compiler to me.  Whose is it, that
we may all avoid buying it?
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	seismo!mimsy!chris	ARPA/CSNet:	chris at mimsy.umd.edu



More information about the Comp.lang.c mailing list