A solution to the multiple inclusion problem

Todd M. Lewis utoddl at uncecs.edu
Wed Oct 25 22:13:08 AEST 1989


In article <1989Oct24.153611.12168 at lotus.com>, mgordon at lotus.com (PCSD Mac) writes:
> 
> How about a new preprocessor directive that means "include this file only 
> if it hasn't already been included", say "#require"?  The "preprocessor"
> would simply keep a table of files that have already been included and use 
> it to avoid including the same #required file more than once.  There will 
> always be files you really do want to #include multiple times, so you can't
> change the meaning of #include.

Could this not be done with a compiler switch?  You could switch it
off if you really did have to include a file multiple times, but
this doesn't happen too often in Real Life (not mine anyway).

Actually, the compiler I use lets me dump its symbol table to a 
file.  Later, I compile with a switch which says "use this here file
to preload your symbol table", and I don't have to process all
those include files every time.  Works like a charm.  If I then
#include a file that is one of the pre-cooked ones in dump file, the
compiler doesn't include it again.  This cuts compile times way down.
_____        
  |      Todd M. Lewis            Disclaimer: If you want my employer's
  ||\/|  utoddl at ecsvax.uncecs.edu             ideas, you'll have to
  ||  || utoddl at ecsvax.bitnet                 _buy_ them. 
   |  ||     
       |___   ("Prgrms wtht cmmnts r lk sntncs wtht vwls." --TML)



More information about the Comp.lang.c mailing list