A solution to the multiple inclusion problem

David S. Masterson cimshop!davidm at uunet.UU.NET
Wed Oct 25 03:19:14 AEST 1989


In article <1659 at atanasoff.cs.iastate.edu> hascall at atanasoff.cs.iastate.edu (John Hascall) writes:

       Since the impending ANSI standard requires that including a file more
       than once have exactly the same effect as including it once...why can't
       a compiler just ignore #includes for files it has already #included???
       (at least for the "standard" includes)

       Any comments from the ANSI mavens?

What????  (I hope this isn't true)

Doesn't the "#if" mechanism suggest that it is very possible to include a file
more than once and have different things happen?  For instance (not a really
good example, though):

setup.h:				main.c:
#ifdef GENERIC				#define GENERIC
#define INTSIZE 16			#include "setup.h"
#endif
#ifdef VAX				processor.c
#define INTSIZE 32			#define VAX
#endif					#include "setup.h"

--
===================================================================
David Masterson					Consilium, Inc.
uunet!cimshop!davidm				Mt. View, CA  94043
===================================================================
		"Nobody here but us chickens..."



More information about the Comp.lang.c mailing list