home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / atari / st / 11904 < prev    next >
Encoding:
Text File  |  1992-07-30  |  1.8 KB  |  52 lines

  1. Newsgroups: comp.sys.atari.st
  2. Path: sparky!uunet!usc!elroy.jpl.nasa.gov!ames!nsisrv!news!dstailey
  3. From: dstailey@leidecker.gsfc.nasa.gov (Douglas Stailey)
  4. Subject: Re: Bug in Pure-C
  5. In-Reply-To: boender@dutiws.tudelft.nl's message of 30 Jul 92 19: 37:08 GMT
  6. Message-ID: <DSTAILEY.92Jul30220937@leidecker.gsfc.nasa.gov>
  7. Sender: usenet@nsisrv.gsfc.nasa.gov (Usenet)
  8. Nntp-Posting-Host: leidecker.gsfc.nasa.gov
  9. Organization: /dstailey/.organization
  10. References: <1932@dutiws.tudelft.nl>
  11. Date: Fri, 31 Jul 1992 03:09:37 GMT
  12. Lines: 38
  13.  
  14. In article <1932@dutiws.tudelft.nl> boender@dutiws.tudelft.nl (P.Boender.TI-tel-4593) writes:
  15.  
  16.  
  17. |  Hi,
  18. |  With a friend of mine, I discovered a bug in Pure-C.
  19. |  In some circumstances, variables that are declared static in a source
  20. |  file (outside of any function) and that are only used in one function,
  21. |  do not actually exist outside of that function. Unless: they are initialised
  22. |  to a value, or the option "Do not use register variables" is set.
  23. |   example:
  24. |
  25. |  #include<many files>
  26. |
  27. |  static int desk_x, desk_y, desk_w, desk_h;
  28. |
  29. |  void window_init(void)
  30. |  {
  31. |  .....
  32. |     handle = wind_get(0, WF_WORKXYWH, &desk_x, &desk_y, &desk_w, &desk_h);
  33. |  .....
  34. |  }
  35.  
  36. Static variables are declared inside functions.  Variables declared outside
  37. of functions are global.  I'm not sure what the compiler is making of your
  38. code, but I do know of one use of the "static" keyword outside of functions,
  39. and that is in function declarations.  In this case, "static" means private,
  40. i.e. not accessable to any code outside of the source module in which the
  41. function is defined.
  42.  
  43.    Doesn't work unless option "do not use register variables" is set.
  44.  
  45. Very interesting, but ...
  46.  
  47. --
  48. Doug
  49. dstailey@leidecker.gsfc.nasa.gov
  50.  
  51. In the spaceship, the tiny spaceship, the lion waves goodbye...
  52.