A solution to the multiple inclusion problem
Jacob Gore
jacob at gore.com
Wed Oct 25 15:57:04 AEST 1989
/ comp.lang.c / gsf at ulysses.homer.nj.att.com (Glenn Fowler[drew]) / Oct 24 /
>>> / comp.lang.c / mgordon at 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 <device, inode> 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 <stdio.h>?
If `#require "stdio.h"' is looking to include /usr/include/stdio.h (or
whatever file `<stdio.h>' refers to).
Jacob
--
Jacob Gore Jacob at Gore.Com boulder!gore!jacob
More information about the Comp.lang.c
mailing list