steveg@sri-unix (09/03/82)
Most versions of the assembler/loader cause routines to be pulled in from libraries if they are mentioned (as in a "extern" or ".globl" declaration), but are never used. Putting routine definitions into include files just invites bigger than needed a.out files (particularly important on 11's - how many times have you gotten stdio pulled in when you didn't want it?). You could of course create separate include files for each routine, but that has obvious lossage. A more permanant solution would be to make the assembler ignore all .globls that are not actually used. I've been thinking about trying this and seeing what breaks. Anyone know of anything that depends on current semantics? Any other comments? Steve Glaser, Tektronix MDP {decvax,ucbvax}!teklabs!steveg UUCP steveg.tektronix@udel-relay ARPANET steveg@tektronix CSNET
chris.umcp-cs@Udel-Relay@sri-unix (09/18/82)
From: Chris Torek <chris.umcp-cs@Udel-Relay> Date: 15 Sep 82 1:57:03-EDT (Wed) Declaring functions in header files does not cost anything in the Portable C Compiler. The compiler does only one thing with function declarations that have no body: put the function into the definitions table with the right type and a definition of "unneeded". When the function is REFERENCED the definition becomes "external".
gwyn@Brl@sri-unix (09/18/82)
From: Doug Gwyn <gwyn@Brl> Date: 15 Sep 82 5:34:54-EDT (Wed) If you don't say "extern" then you haven't made a reference unless you actually USE the routine. e.g. in <math.h> double cos(), sin(); but you don't get these included by the linker unless you reference them (or if something you reference references them, ... [closure]). A nice feature is that the sin/cos routine source can include <math.h> with no conflict. In fact, this is one of the few reasons I know of for the continued existence of the non-static/extern outer block declarations.
dan@Bbn-Unix@sri-unix (09/18/82)
From: Dan Franklin <dan@Bbn-Unix> Date: 15 Sep 1982 13:18:00 EDT (Wednesday) Regardless of what most aassemblers and loaders may do, many C compilers (including 4.1 BSD and the Ritchie compilers) do not generate .globls if you declare, but do not reference, an external function. So just because stdio.h declares fopen, freopen, fdopen, ftell, and fgets doesn't mean that all those routines are included in your object files.
thomas (09/20/82)
When you're using PCC, if you do say extern, then NO storage is even allocated. Extern applied to data items generates an undefined reference if the data item is not declared somewhere without an extern. Extern applied to functions is exactly the same as declaring a function without saying extern. =Spencer