A solution to the multiple inclusion problem
PCSD Mac
mgordon at lotus.com
Wed Oct 25 01:36:11 AEST 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. There will
always be files you really do want to #include multiple times, so you can't
change the meaning of #include.
I believe that would do the trick, and it wouldn't break any existing
programs. If you use this construct though, you can't go back to compilers
that don't support it.
More information about the Comp.lang.c
mailing list