Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!sunybcs!boulder!hao!oddjob!gargoyle!ihnp4!alberta!ers!teletron!andrew From: andrew@teletron.UUCP Newsgroups: comp.lang.c Subject: Initialization of Externals (was Re: documentation standards...) Message-ID: <123@teletron.UUCP> Date: Tue, 27-Oct-87 19:08:23 EST Article-I.D.: teletron.123 Posted: Tue Oct 27 19:08:23 1987 Date-Received: Sat, 31-Oct-87 09:15:08 EST References: <9897@brl-adm.ARPA> <6917@prls.UUCP> Organization: TeleTronic Communications Ltd., Edmonton, Alta. Lines: 30 Summary: variable initialization 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. Sometimes you have no choice.. (see below) In article <6917@prls.UUCP>, gardner@prls.UUCP (Robert Gardner) writes: > I prefer compile-time initialization when possible, but it's not > necessarily "for free". This is true when dealing with ROM-able code. You are forced to write explicit 'initialize()' procedures. Our compiler (like most others) generates different segments for different portions of code: .text - program instructions .data - initialized externals .bss - uninitialized externals We bind the .text and .data sections to ROM addresses and .bss sections to RAM addresses at link time. Thus, we are forced to allow initialized externals for static data structures only. Variable data must be initialized by an 'initialize()' routine called from the startup code. I realize this is a digression from the original thread, and Tom's original point about documentation of variable initialization is well taken, but one can't always use compile-time initialization. Andrew