Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!sri-spam!robert From: robert@sri-spam.UUCP Newsgroups: comp.lang.c Subject: Re: default initialization of static and extern Message-ID: <10314@sri-spam.istc.sri.com> Date: Wed, 3-Jun-87 18:32:19 EDT Article-I.D.: sri-spam.10314 Posted: Wed Jun 3 18:32:19 1987 Date-Received: Sat, 6-Jun-87 04:13:46 EDT References: <158@delftcc.UUCP> <1070@viper.Lynx.MN.ORG> <1297@genrad.UUCP> <675@gargoyle.UChicago.EDU> Reply-To: robert@sri-spam.UUCP (Robert Allen) Organization: SRI International, Menlo Park Lines: 27 Keywords: C, NULL, portability In article <675@gargoyle.UChicago.EDU> mason@gargoyle.uchicago.edu.UUCP (Tony Mason) writes: >In article <1297@genrad.UUCP> rep@genrad.UUCP (Pete Peterson) writes: >>K&R claims (in at least 3 places) that externs and statics are >>guaranteed to be initialized to zero... > > .......... I have >never seen any other compiler that didn't conform to this convention, but it >is best never to assume anything. > This may be a small point, but I always "assume" that static variables local to a function are initialized to zero, and maintain their value over time and function calls. If this not the case, how can one effectively determine what to initialize to? If you init explictly then it will be done each time you call the function, so the routine isn't static. Am I missing something? Does C provide that an "initialization when declaration" in a function only occurs once? Anything less than 'assuming 0' just isn't correct C in my book. (and in K&R's to boot! :-) ) -- --------------------------------------------------------- Who? Me? Robert Allen, robert@spam.istc.sri.com ---------------------------------------------------------