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