Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!oliveb!sun!gorodish!guy From: guy@gorodish.UUCP Newsgroups: comp.lang.c Subject: Re: default initialization of static and extern Message-ID: <20333@sun.uucp> Date: Wed, 3-Jun-87 21:22:49 EDT Article-I.D.: sun.20333 Posted: Wed Jun 3 21:22:49 1987 Date-Received: Sat, 6-Jun-87 04:36:52 EDT References: <158@delftcc.UUCP> <1070@viper.Lynx.MN.ORG> <1297@genrad.UUCP> <10314@sri-spam.istc.sri.com> Sender: news@sun.uucp Lines: 22 Keywords: C, NULL, portability > 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? Yes, you're missing something, because C does provide that an "initialization when declared" only occurs once if the variable being initialized is static: 9.2 Compound statement, or block ... Any initializations of "auto" or "register" variables are performed each time the block is entered at the top. ... Initializations of "static" variables are performed only once when the program begins execution. The code of a function is considered to be a block here. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com