Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rochester!cornell!batcomputer!braner From: braner@batcomputer.tn.cornell.edu (braner) Newsgroups: comp.lang.c Subject: Re: A Deficiency of the C Preprocessor Message-ID: <1888@batcomputer.tn.cornell.edu> Date: Fri, 19-Dec-86 14:07:43 EST Article-I.D.: batcompu.1888 Posted: Fri Dec 19 14:07:43 1986 Date-Received: Sat, 20-Dec-86 06:20:11 EST References: <1259@kontron.UUCP> Reply-To: braner@batcomputer.UUCP (braner) Organization: Theory Center, Cornell University, Ithaca NY Lines: 26 Summary: Right on! Also a deficiency in compilers In article <1259@kontron.UUCP> cramer@kontron.UUCP (Clayton Cramer) writes: >I've got a complaint about the C preprocessor -- I doesn't support a >repetition for initializing data structures. > ... >We've worked around this annoyance by defining a function that initializes >the FooBar, but this takes time and code to do at runtime something that >should be doable at compile time. ... I would like, if not that, at least an acceptance by the preprocessor of more parameters than required. As for compile vs. run time initialization of arrays: A compiler I use creates code for all the initializations in the program, code that runs when you invoke the program and copies all the initial data from the code to the variable-data areas. (To sound technical: from the data (or code) segment to the bss segment.) This means that during the execution of the program, TWICE the memory is needed to hold the data. This is necessary in environments where code is not to be modified (e.g. ROM), but in other environments is wasteful. 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. This approximately DOUBLES the length of the initialization section of the code (and the total memory use is now TRIPLE what it could be...). Is this typical for C compilers? Could you compiler-writers avoid this in the future, please? - Moshe Braner