Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!pyramid!prls!gardner From: gardner@prls.UUCP (Robert Gardner) Newsgroups: comp.lang.c Subject: Re: documentation standards........ Message-ID: <6917@prls.UUCP> Date: Fri, 23-Oct-87 12:45:14 EST Article-I.D.: prls.6917 Posted: Fri Oct 23 12:45:14 1987 Date-Received: Sun, 25-Oct-87 17:03:05 EST References: <9897@brl-adm.ARPA> Reply-To: gardner@prls.UUCP (Robert Gardner) Organization: Philips Research Labs, Sunnyvale, California Lines: 21 In article <9897@brl-adm.ARPA> tom@vax1.acs.udel.EDU (Tom Uffner) writes: >all externals and statics can be >initialized "for free" to nearly anything desired at compile time, >(cf. constant expressions) but an 'initialize()' proc would generate >code and take time to execute. This isn't necessarily true and depends on the details of the linker and loader (and compiler implementation). One compiler I worked with allocates space for global variables dynamically before calling main(), zeroes it, and then executes a bunch of initialization statements that move the initialization values into the proper places, then calls main(). There is approx. one move for each initializer, so each initializer takes about twice as much space as you would expect. On the other hand, this is a net gain if there are only a few initializers compared to the number of global variables, since allocating space for all the global variables in the executable (as RSX does) can take more space than the initialization code if there are a lot of globals. I prefer compile-time initialization when possible, but it's not necessarily "for free". Robert Gardner