conditional includes

joe at modcomp.UUCP joe at modcomp.UUCP
Sun Jan 15 12:21:00 AEST 1989


Peter da Silva's discussion of the following construct [slightly modified]:

  main.c
  	...
	#include "windows.h"
	#include "menus.h"
  	...

  windows.h:				menus.h
  	...					...
  	#ifndef GRAPHICS_H			#ifndef GRAPHICS.H
  	#include "graphics.h"			#include "graphics.h"
	#define GRAPHICS_H			#define GRAPHICS.H
  	#endif					#endif
  	...					...

reminded me of a feature that I've always wanted in cpp: the ability to do
conditional includes in a way less clumsy than the above examples.
Specifically, I would like cpp to remember which files have already been
included, and to automatically NOP any extra requests.  Of course, a
conditional include service should not be called "#include".  Perhaps
"#cinclude"?

The idea is obvious enough that it probably has occurred to others.  Have
any of you run across an implementation?  What problems have come up with
it?  Or do you consider it trivial and thus would just be another instance
of "creeping featurism" in the language?  Your thoughts would be appreciated.

joe korty
uunet!modcomp!joe

PS: Send email if you like; I'll be glad to correlate and summarize the
responses.



More information about the Comp.lang.c mailing list