Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!eecae!netnews.upenn.edu!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Include files Message-ID: <9526@smoke.BRL.MIL> Date: 28 Jan 89 04:18:11 GMT References: <10991@umn-cs.CS.UMN.EDU> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 35 In article <10991@umn-cs.CS.UMN.EDU> raghavan@umn-cs.cs.umn.edu (Vijay Raghavan) writes: - Is the Sun style of surrounding the text of standard "include" files -with a #ifndef-#endif pair really okay? Specifically, does the standard -condone/permit/require stdio.h (say) to have the following structure: -#ifndef FILE - ... -#define FILE struct _iobuf - ... -#endif !__FILE Well, more or less. There are several detailed points involved here. - If it does, programs like the following should not compile: -main() { -#include -FILE *xx; -... -} -proc1() { -#include -FILE *yy; -... -} The first point is that the standard headers may be included only outside all function bodies (i.e. at file scope level). The next point is that a #defined macro's scope extends to the end of the translation unit, not just to the end of a block. The third point is that FILE should be a typedef, not a #define. The final point is that the standard headers may be included more than once with no effect different from being included exactly once. This is what the "#ifndef FILE" was attempting to accomplish.