Separate compilation
The interface file hash.h


typedef . . . HASHTABLE;

HASHTABLE create();
HASHSLOT enter();
HASHSLOT lookup();

#define HT_MAXTABLESIZE 50

external int global_hash_data;

The supplier file hash.c


#include "hash.h"

int global_hash_data;

HASHSLOT
lookup(HASHTABLE ht, char *name)
{
. . .
}

% cc -c hash.c

This produces an object file hash.o whose symbol table defines the external
symbols global_hash_data and lookup.

 

The client file hashtest.c

#include "hash.h"

HASHTABLE my_table;

main()
{
HASHSLOT aSlot;
....my_table = create();
....enter(my_table, "Look Homeward, Angel");
....aSlot = lookup(my_table, "Eugene Gant");
....printf("%d", global_hash_data);
}

% cc -c hashtest.c

This produces an object file hashtest.o containing unresolved references to
....external symbols lookup and global_hash_data.

% cc -o hashtest hash.o hashtest.o

This resolves the dangling references in hashtest.o using the definitions
....in hash.o, and produces an executable file hashtest. No compilation
... is done, only linking and loading.