home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 17020 < prev    next >
Encoding:
Text File  |  1992-11-22  |  1.6 KB  |  38 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!paladin.american.edu!news.univie.ac.at!hp4at!sca
  3. From: sca@gese.ge14.mdadv.gv.at (Petzi Schweda)
  4. Subject: Re: C coding style
  5. Message-ID: <1992Nov23.092816@gese.ge14.mdadv.gv.at>
  6. Originator: sca@gese0n.ge14.mdadv.gv.at
  7. Sender: usenet@hp4at.eunet.co.at (USENET - Admin account)
  8. Nntp-Posting-Host: gese.ge14.mdadv.gv.at
  9. Organization: MD-ADV, Vienna, Austria
  10. References:  <1992Nov20.213253.386@cs.mcgill.ca>
  11. Distribution: NA
  12. Date: Mon, 23 Nov 1992 08:28:16 GMT
  13. Lines: 23
  14.  
  15.  
  16. In article <1992Nov20.213253.386@cs.mcgill.ca>, iceman@honey.cs.mcgill.ca writes:
  17. |> Hello,
  18. |> 
  19. |>     What kind of convention is usually used for naming global variables?
  20. |>     I know Apple recommends adding a lower-case 'g' in front of the
  21. |>     variable name, e.g. gDeviceList. However, when using multi-file
  22. |>     projects, this doesn't differentiate between static globals (private
  23. |>     to the module) and extern globals (public globabls that can be
  24. |>     refered to from outside the module they're declared in).
  25. |> 
  26. |> --
  27.  
  28. I would strongly recommend to avoid global variables at all !!!
  29. Extern (non-static) globals give you lot's of problems when you organize your code (maybe later ?) in shareable images (I've ran into this under VMS and with Windows-DLL's).
  30. Static (module-wide) globals must be handled VERY carefully to keep your code reentrant (sp?) and reusable. 
  31. Nearly any static I've used (expect from the typical "is_initialized") to store control-data did kick me in the ass in the worst moment it could ...
  32.  
  33. be aware, petzi
  34.  
  35. Petzi Schweda (sca@gese.ge14.mdadv.gv.at)
  36. MD-ADV, Municipality of the City of Vienna, Austria
  37.   
  38.