Newsgroups: comp.lang.c Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!snorkelwacker.mit.edu!thunder.mcrcim.mcgill.edu!mouse From: mouse@thunder.mcrcim.mcgill.edu (der Mouse) Subject: Re: include files -- help needed Message-ID: <1991Jun29.124841.21868@thunder.mcrcim.mcgill.edu> Organization: McGill Research Centre for Intelligent Machines References: <1966@nixsin.UUCP> <1991Jun20.170144.1109@keinstr.uucp> <1991Jun26.213114.236@druid.uucp> Date: Sat, 29 Jun 91 12:48:41 GMT Lines: 37 In article <1991Jun26.213114.236@druid.uucp>, darcy@druid.uucp (D'Arcy J.M. Cain) writes: > In article <1991Jun26.091408.5023@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@larry.mcrcim.mcgill.edu