Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!crdgw1!camelback!volpe From: volpe@camelback.crd.ge.com (Christopher R Volpe) Newsgroups: comp.lang.c Subject: Re: Just above and below main() Message-ID: <18507@crdgw1.crd.ge.com> Date: 15 Apr 91 13:08:13 GMT References: <1243@nanometrics.UUCP> <18473@crdgw1.crd.ge.com> <111@hdwr1.medar.com> Sender: news@crdgw1.crd.ge.com Reply-To: volpe@camelback.crd.ge.com (Christopher R Volpe) Lines: 37 In article <111@hdwr1.medar.com>, jseymour@medar.com (James Seymour) writes: |>Very good idea. Better yet, the manual specific to the compiler package |>*you* are using. On some older compilers, you needed to explicitly ^^^^^ By "older" I assume you mean "broken"??? |>initialize globals in the file they were intended to be *defined* in. All |>other occurances of things like the declaration of "outside" (as above) |>were assumed to be a reference to an external that was defined in another |>file. If you didn't have a global initialized at least once, the symbol |>for it was never defined, and thus the link phase would fail. The behavior you are describing does not correspond to the C language described either by ANSI or by K&R1. It doesn't make much sense to point out every possible way a compiler can do the wrong thing whenever you tell someone what the language guarantees, IMHO. |> In newer |>compilers however, declarations like that in the original question above |>result in "outside" being global, it is defined in the file that contains |>the above declaration (it is not preceded with the word "extern"), and the |>space it occupies is initialized to zero. Regardless of what newer |>compilers do with globals however, IMHO it is best to explicitly initialize |>such variables if you expect them to start with a known value - even 0. Agreed. |>-- |>Jim Seymour | Medar, Inc. |>...!uunet!medar!jseymour | 38700 Grand River Ave. |>jseymour@medar.com | Farmington Hills, MI. 48331 |>CIS: 72730,1166 GEnie: jseymour | FAX: (313)477-8897 ================== Chris Volpe G.E. Corporate R&D volpecr@crd.ge.com