From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gabriel Dos Reis To: Stan Shebs Cc: Devang Patel , gcc@gcc.gnu.org Subject: Re: tree.h vs include guard Date: Tue, 13 Aug 2002 20:31:00 -0000 Message-id: References: <3D59C969.5070403@apple.com> X-SW-Source: 2002-08/msg00807.html Stan Shebs writes: | Devang Patel wrote: | | > We already have guard in our Darwin sources for tree.h | | We have it for a reason - tree.h is included (dubiously IMHO) in one of | the PFE headers. I don't see a reason for the mainline to have it though. Well, I was working on a pretty-printer for C and C++ when I noticed how painful it was for not having tree.h protect against multiple inclusion. | | > | > I do not know, if there is particular reason for not providing guards | > for headers. | > At one time, I saw many headers without include protection guards. | | I thought the current policy was only to include guards if they were really | necessary, and for most headers they aren't. In general GCC policy is to | explicitly include every header needed by a source file. That is what I did for c-pretty-print.[hc] which needed bits from tree.h. and latter when I included c-pretty-print.h in cp/error.c I got complaints from the compiler -- realizing minutes later that it was because tree.h was being included multiple times. Not having guard for tree.h means reorganization of the include each time a bits is added somewhere. Not a scalable scheme, IMO. Note that c-tree.h, c-common.h, cp-tree.h already have guards. -- Gaby