include files -- help needed

der Mouse mouse at thunder.mcrcim.mcgill.edu
Sat Jun 29 22:48:41 AEST 1991


In article <1991Jun26.213114.236 at druid.uucp>, darcy at druid.uucp (D'Arcy J.M. Cain) writes:
> In article <1991Jun26.091408.5023 at thunder.mcrcim.mcgill.edu> der Mouse writes:
>>> #ifndef FOOBAR_H
>>> #define FOOBAR_H
>>> ...
>>> #endif
>> I used to do that too, until I found I had two time.h files, both
>> using TIME_H.  So now I tack on a 32-bit hash of the file contents
> Why go through that?  I assume you mean that you have something like
> time.h and sys/time.h so just prepend _SYS_ to the defines in the sys
> directory:

>   #ifndef _SYS_TIME_H
>   #define _SYS_TIME_H

Because there's no end to that.  Should I prepend
_USR_INCLUDE_SYS_TIME_H?  Or perhaps just _INCLUDE_SYS_TIME_H?  Why
should some of the leading directories be included but not the rest?

And I can't just strip off /usr/include, because the same scheme is
used for include files elsewhere.  Perhaps I should do _SYS_TIME_H and
then _THUNDER_HOME_SHAMASH_MOUSE_SUN4_INCLUDE_HTABLE_H for the htable.h
in my own include directory?

Ideally, the protection would protect against any inclusion of the same
file multiple times.  But there's no simple way to ensure that.

I suppose I could take the entire contents of the file, somehow process
it (reversibly) into a unique string that's a legal cpp symbol, and use
that.  But that triples the size of the file and will break some cpps
and stress the rest.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse at larry.mcrcim.mcgill.edu



More information about the Comp.lang.c mailing list