Path: utzoo!utgpu!watserv1!watmath!att!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!acorn!ixi!clive From: clive@x.co.uk (Clive Feather) Newsgroups: comp.windows.x Subject: Re: time.h Message-ID: Date: 28 Nov 90 13:10:58 GMT References: <9011190128.AA05620@wintermute.fullerton.edu> <9011191648.AA22040@excess.lcs.mit.edu> Reply-To: clive@x.co.uk (Clive D.W. Feather) Organization: IXI Limited, Cambridge, UK Lines: 33 In article <9011191648.AA22040@excess.lcs.mit.edu> converse@EXPO.LCS.MIT.EDU writes: > Header files often contain the definition of a preprocessor symbol > which can be used to prevent the error of including a header file more than > once, by wrapping the include. > > #ifndef __XTIME__ > #include > #endif > > But it is not clear to me whether these symbols are defined by any standard. There is no standard naming these includes. POSIX (IS 9945-1 / IEEE 1003.1) and ANSI C (DIS 9989 / ANSI X3.159) both require that all the header files they define must be idempotent - i.e. including them a second or subsequent time must have no effect. The easiest way to do this is with such a symbol in the include file: #ifndef __XTIME__ #define __XTIME__ [contents of sys/time.h] #endif /* __XTIME__ */ /* DON'T put anything after this endif */ In addition, ANSI C says that symbols beginning with double underscore or with underscore followed by a capital letter are reserved for the implementation in this context (this can include special treatment by the compiler), so you should take care in doing this yourself. Note that this rule makes the MIT distribution non-conformant if used standalone. -- Clive D.W. Feather | IXI Limited | If you lie to the compiler, clive@x.co.uk | 62-74 Burleigh St. | it will get its revenge. Phone: +44 223 462 131 | Cambridge CB1 1OJ | - Henry Spencer (USA: 1 800 XDESK 57) | United Kingdom |