Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!lll-lcc!pyramid!voder!kontron!cramer From: cramer@kontron.UUCP (Clayton Cramer) Newsgroups: comp.lang.c Subject: A Deficiency of the C Preprocessor Message-ID: <1259@kontron.UUCP> Date: Thu, 18-Dec-86 15:25:10 EST Article-I.D.: kontron.1259 Posted: Thu Dec 18 15:25:10 1986 Date-Received: Fri, 19-Dec-86 21:59:47 EST Organization: Kontron Electronics, Mt. View, CA Lines: 38 I've got a complaint about the C preprocessor -- I doesn't support a repetition for initializing data structures. We are developing programs where an array of structures exists. #define BRKPTCOUNT 5 struct .... FooBar[BRKPTCOUNT] = {....}; Everytime we change BRKPTCOUNT, we have to change the initialization data for FooBar; if we give extra initialization data, we get complaints from the compiler; if we don't give enough data, the rest of the structure isn't initialized. 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. Something equivalent to the assembler directive DUP would be ideal, since it would allow us to replace the lines above with: #define BRKPTCOUNT 5 struct .... FooBar[] = {5 DUP {....}}; and scrap the initialization code. We COULD build our own preprocessor to take care of this, but a general solution, perhaps as part of some future version of the ANSI C spec would be better. Clayton E. Cramer "You cannot bring about prosperity by discouraging thrift. You cannot strengthen the weak by weakening the strong. You cannot help the wage earner by pulling down the wage payer. You cannot further the brother- hood of man by encouraging class hatred. You cannot keep of out of trouble by spending more than you earn. You cannot build character and courage by taking away man's initiative and independence. You cannot help men permanently by doing for them what they could and should do for themselves." -- Abraham Lincoln