A Deficiency of the C Preprocessor

Gregory Smith greg at utcsri.UUCP
Tue Dec 23 07:56:30 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.
>
In article <4863 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
>Why is this a complaint about the preprocessor?  The preprocessor
>knows nothing about data structures.

Yes, but it could still make repeated text, which could be used to
create repeated data structures, code, or what have you. You
have missed Clayton's point.

>In article <1888 at batcomputer.tn.cornell.edu>
>braner at batcomputer.tn.cornell.edu (braner) writes:
>>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.
>
[Chris again].
>That sounds like a pretty poor compiler to me.  Whose is it, that
>we may all avoid buying it?

I have never seen a C compiler that does this, but I know of another
supposedly powerful language compiler that does. And of course there
is P*sc*l, which not only does this but forces the programmer to write
out the code too [i.e. there are no compile-time inits].

It isn't really that bad on a virtual memory machine, since the initial-
ization code is only used once, and will be quickly paged out forever.
Hopefully the link environment is such that this code is
all bunched together.

If I say:
foo(){
	static int bar=0;
	...
then 'bar' must be set to zero sometime before the first call to 'foo', and
must *not* be set to zero on subsequent calls to foo. On braner's compiler,
does this work, and if so, how? Does the compiler put 'CLR bar' into a
separate code area which is executed at startup? This sounds like more
trouble than real initialization...
-- 
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg
Have vAX, will hack...



More information about the Comp.lang.c mailing list