Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!atha!lsuc!jimomura From: jimomura@lsuc.on.ca (Jim Omura) Newsgroups: comp.sys.atari.st Subject: Re: static globals? [addendum to previous message] Message-ID: <1991May2.023651.7292@lsuc.on.ca> Date: 2 May 91 02:36:51 GMT References: <1991Apr30.183034.15773@lsuc.on.ca> <1991May1.020731.16272@wam.umd.edu> Organization: Consultant, Toronto Lines: 29 In article <1991May1.020731.16272@wam.umd.edu> dmb@wam.umd.edu (David M. Baggett) writes: >In article <1991Apr30.183034.15773@lsuc.on.ca> jimomura@lsuc.on.ca (Jim Omura) writes: >> I've never seen this type of declaration before. Why would you >>bother to declare a "global" as a "static"? Is there any point to >>it? It doesn't seem to be a problem for the compilers to handle. > >Oops, I forgot one crucial point in my previous message. If you >declare a global variable as "static" then it will not be exported out >of the .o file it appears in. So static vs. auto makes a difference >with respect to separate compilation. The static storage class is >very useful for avoiding name clashes between modules. >If you're not using separate compilation; i.e., if you have one >giant .c file or #include everything all at once, then static >vs. auto makes little difference for globals. Many thanks to all who have replied to my query! After reading this message I remembered all about "static globals". Ironically, I learned it years ago and forgot about it a couple of years ago and asked exactly the same question at that time. Then I remembered when someone else answered. So here I am about 2 years later asking it all over again. Truth is, I'll probably forget and have to ask again in another couple of years. Gads. No hope for me at all. :-) -- Jim Omura, 2A King George's Drive, Toronto, (416) 652-3880 lsuc!jimomura Byte Information eXchange: jimomura