home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.atari.st
- Path: sparky!uunet!usc!elroy.jpl.nasa.gov!ames!nsisrv!news!dstailey
- From: dstailey@leidecker.gsfc.nasa.gov (Douglas Stailey)
- Subject: Re: Bug in Pure-C
- In-Reply-To: boender@dutiws.tudelft.nl's message of 30 Jul 92 19: 37:08 GMT
- Message-ID: <DSTAILEY.92Jul30220937@leidecker.gsfc.nasa.gov>
- Sender: usenet@nsisrv.gsfc.nasa.gov (Usenet)
- Nntp-Posting-Host: leidecker.gsfc.nasa.gov
- Organization: /dstailey/.organization
- References: <1932@dutiws.tudelft.nl>
- Date: Fri, 31 Jul 1992 03:09:37 GMT
- Lines: 38
-
- In article <1932@dutiws.tudelft.nl> boender@dutiws.tudelft.nl (P.Boender.TI-tel-4593) writes:
-
-
- | Hi,
- | With a friend of mine, I discovered a bug in Pure-C.
- | In some circumstances, variables that are declared static in a source
- | file (outside of any function) and that are only used in one function,
- | do not actually exist outside of that function. Unless: they are initialised
- | to a value, or the option "Do not use register variables" is set.
- | example:
- |
- | #include<many files>
- |
- | static int desk_x, desk_y, desk_w, desk_h;
- |
- | void window_init(void)
- | {
- | .....
- | handle = wind_get(0, WF_WORKXYWH, &desk_x, &desk_y, &desk_w, &desk_h);
- | .....
- | }
-
- Static variables are declared inside functions. Variables declared outside
- of functions are global. I'm not sure what the compiler is making of your
- code, but I do know of one use of the "static" keyword outside of functions,
- and that is in function declarations. In this case, "static" means private,
- i.e. not accessable to any code outside of the source module in which the
- function is defined.
-
- Doesn't work unless option "do not use register variables" is set.
-
- Very interesting, but ...
-
- --
- Doug
- dstailey@leidecker.gsfc.nasa.gov
-
- In the spaceship, the tiny spaceship, the lion waves goodbye...
-