A Modest Extension to the C Preprocessor

John B. Nagle jbn at wdl1.UUCP
Thu Aug 2 05:48:02 AEST 1984


I propose that a new preprocessor directive be defined as follows:

	#use FILENAME

to be interpreted identically to ``#include'', except that if FILENAME
has already been included (either via #include or #use) during this
compilation, #use does nothing.


The intent here is to resolve the problem of dependency in header files.
If all header files (``*.h'') by convention contain #use statements for all 
the header files they need, then C program text files (``*.c'') need only
include the files the C program itself needs, and need not worry about
internal dependencies in header file libraries.  So this does for header
files what linkers do for object files.

It might seem tempting to change the semantics of #include to work this way,
but this would introduce an incompatibility; some programs may be using
#include to include things of which they want multiple copies.

Portability would be increased by this enhancement, since at present the
dependency structure of header files is not standardized, even between
versions of UNIX (anyone doubting this should port something from V7 to 
system 5), and with this enhancement, the internal structure of the header 
files disappears from the user's programs.

Comments?

					John Nagle
					Ford Aerospace and Communications Corp.



More information about the Comp.lang.c mailing list