home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / c / 11387 < prev    next >
Encoding:
Internet Message Format  |  1992-07-20  |  2.1 KB

  1. Path: sparky!uunet!mcsun!uknet!qmw-dcs!nuntius
  2. From: R.S.Jones@qmw.ac.uk (Robert S. Jones)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Summary: Why use "extern" on function prototypes.
  5. Message-ID: <1992Jul21.070641.13516@dcs.qmw.ac.uk>
  6. Date: 21 Jul 92 07:06:41 GMT
  7. References: <12271@anderson>
  8. Sender: usenet@dcs.qmw.ac.uk (Usenet News System)
  9. Organization: Queen Mary & Westfield College (London)
  10. Lines: 28
  11. Nntp-Posting-Host: rsj.css.qmw.ac.uk
  12. X-Useragent: Nuntius v1.1
  13.  
  14. In article <12271@anderson> David Anderson, anderson@Software.Mitel.COM writes:
  15. > From Mike: ARIEL.LERC.NASA.GOV!SMNEYLN@uunet.ca Tue Jul  7 13:06:09 1992
  16. >
  17. > I checked in 'C the Complete Reference' by the C god himself, H.Schildt.
  18. > He says that extern variables (and functions) are not allocated in that
  19. > section of the program.  Thus, I think extern, although not necessary in
  20. > headers, is used to reduce memory considerations.  Take a look at a 
  21. > Windows program on DOS machines.  The program must obviously be written
  22. > in several parts, using the same header files (ie stdio.h).  If the
  23. > header file did not have extern for each proto, memory would be allocated
  24. > for the functions several times.  So if i use stdio.h in a hundred part
  25. > program, I might just zap a good 100k of memory just to the extra allocation
  26. > However, if I extern the header, I would only allocate the memory once (in
  27. > the actual library), and save that precious 100k.
  28.  
  29. Disclaimer. I am NO expert, nor probably even a minor deity.
  30.  
  31. But, surely the point is being missed here. Headers are (mostly) not magic,
  32. just bits of text idempotently [:-)] dragged in to your C masterpiece
  33. at the point you #include them. What on earth do you expect <stdio.h> to
  34. allocate 100k for? There is no code in it - only definitions. If your C 
  35. libraries and linker are any good you should only get ONE copy of each
  36. routine you ACTUALLY call in your "chef d'oeuvre" in the linked module.
  37. >
  38. --
  39. Robert S. Jones -- Computer Systems Manager | The opinions stated above are
  40. Queen Mary & Westfield College, London U.K. | not necessarily .. no, dammit
  41. X-Voice: +44 71 975 5326                    | ... these are the facts!! :-)
  42.