A solution to the multiple inclusion problem
Jonathan Shapiro
shap at delrey.sgi.com
Wed Oct 25 09:07:03 AEST 1989
Okay, here's another cute trick.
Have an include file called include-files.h, which contains things
like
#define FRED_H "fred.h"
#define WILMA_H "wilma.h"
include them by doing the following in all source files:
#include "include-files.h" // done once in all source files
#include FRED_H
#include ...
inside FRED_H do the following:
#ifdef FRED_H
#undef FRED_H
#define FRED_H /dev/null
#endif
This works, doesn't require much overhead, and can be automatically
done applied to existing code by a fairly simple shell script.
Jonathan S. Shapiro
Synergistic Computing Associates
More information about the Comp.lang.c
mailing list