jimomura@lsuc.on.ca (Jim Omura) (05/01/91)
I've been working at a port of Rodney Volz' Mercury and there's a fair bit of strangeness in some of the sources. In the 'elm.c' module I have had some strange problems with the Sozobon C TOP optimizer. I think that this is not critical, but I decided to look for problems in the source code. One thing I've found is that he declared a bunch of variables globally and made them "static". This didn't seem to be a problem for the compiler, but I #ifdef'd them out and replaced them with non-"static" declarations. 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. -- Jim Omura, 2A King George's Drive, Toronto, (416) 652-3880 lsuc!jimomura Byte Information eXchange: jimomura
dmb@wam.umd.edu (David M. Baggett) (05/01/91)
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. Technically, only static variables are guaranteed to be automatically initialized to zeros. Also, I think that only _static_ globals can be given initializers, although most compilers seem to accept initialized auto globals as well. That may be an extension, however. Dave Baggett dmb%wam.umd.edu@uunet.uunet.net
healy@cod.NOSC.MIL (Mike Healy) (05/02/91)
Declaring a global static makes it inaccessible to other modules while global to the functions in the module it is declared in. Mike Healy