Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!sunybcs!boulder!gore!jacob From: jacob@gore.com (Jacob Gore) Newsgroups: comp.lang.c Subject: Re: A solution to the multiple inclusion problem Message-ID: <470006@gore.com> Date: 25 Oct 89 05:57:04 GMT References: <14240@well.UUCP> Reply-To: jacob@gore.com (Jacob Gore) Organization: Gore Enterprises Lines: 35 / comp.lang.c / gsf@ulysses.homer.nj.att.com (Glenn Fowler[drew]) / Oct 24 / >>> / comp.lang.c / mgordon@lotus.com (PCSD Mac) / Oct 24, 1989 / >>> 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. >>[...] >the file equivalence relation may be hard to define, e.g., for unix, given > > ln x.h y.h You are including files, not filenames. So instead of keeping track of files by their names, you do it by pair, or whatever it is on your system that uniquely identifies a file. > will #require "y.h" include y.h following #include "x.h"? No. (I tried it on NeXT's Objective-C compiler, and it didn't.) > are "y.h" and "./y.h" the same file? Yes. > are "y.h" and "/home/gsf/news/y.h" the same file? That I don't know :-) > will #require "stdio.h" include stdio.h after #include ? If `#require "stdio.h"' is looking to include /usr/include/stdio.h (or whatever file `' refers to). Jacob -- Jacob Gore Jacob@Gore.Com boulder!gore!jacob