public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* tree.h vs include guard
@ 2002-08-13 17:57 Gabriel Dos Reis
  2002-08-13 19:21 ` Devang Patel
  2002-08-26  0:18 ` Zack Weinberg
  0 siblings, 2 replies; 9+ messages in thread
From: Gabriel Dos Reis @ 2002-08-13 17:57 UTC (permalink / raw)
  To: gcc

Hi,

  I noticed that tree.h has no guard to prevent multiple-inclusions.
Why so?  FWIW, c-tree.h, c-common.h and cp-tree.h do have such a
thing.

-- Gaby

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tree.h vs include guard
  2002-08-13 17:57 tree.h vs include guard Gabriel Dos Reis
@ 2002-08-13 19:21 ` Devang Patel
  2002-08-26  0:18 ` Zack Weinberg
  1 sibling, 0 replies; 9+ messages in thread
From: Devang Patel @ 2002-08-13 19:21 UTC (permalink / raw)
  To: Gabriel Dos Reis; +Cc: gcc

We already have guard in our Darwin sources for tree.h

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.

On Tuesday, August 13, 2002, at 05:54  PM, Gabriel Dos Reis wrote:

Hi,

  I noticed that tree.h has no guard to prevent multiple-inclusions.
Why so?  FWIW, c-tree.h, c-common.h and cp-tree.h do have such a
thing.

-- Gaby

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tree.h vs include guard
  2002-08-13 17:57 tree.h vs include guard Gabriel Dos Reis
  2002-08-13 19:21 ` Devang Patel
@ 2002-08-26  0:18 ` Zack Weinberg
  2002-08-26  2:22   ` Gabriel Dos Reis
  1 sibling, 1 reply; 9+ messages in thread
From: Zack Weinberg @ 2002-08-26  0:18 UTC (permalink / raw)
  To: Gabriel Dos Reis; +Cc: gcc

On Wed, Aug 14, 2002 at 02:54:29AM +0200, Gabriel Dos Reis wrote:
> 
> Hi,
> 
>   I noticed that tree.h has no guard to prevent multiple-inclusions.
> Why so?  FWIW, c-tree.h, c-common.h and cp-tree.h do have such a
> thing.

Patches to add multiple include guards to all of GCC's internal
headers have been submitted in the past, but never approved and
applied, probably because they'd need an OK from someone with global
write privileges and all those people were too busy to review the
patch.

It was agreed, last time this came up, that in principle they should
all have guards.

zw

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tree.h vs include guard
  2002-08-26  0:18 ` Zack Weinberg
@ 2002-08-26  2:22   ` Gabriel Dos Reis
  2002-08-29 16:48     ` Zack Weinberg
  0 siblings, 1 reply; 9+ messages in thread
From: Gabriel Dos Reis @ 2002-08-26  2:22 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: gcc

Zack Weinberg <zack@codesourcery.com> writes:

| On Wed, Aug 14, 2002 at 02:54:29AM +0200, Gabriel Dos Reis wrote:
| > 
| > Hi,
| > 
| >   I noticed that tree.h has no guard to prevent multiple-inclusions.
| > Why so?  FWIW, c-tree.h, c-common.h and cp-tree.h do have such a
| > thing.
| 
| Patches to add multiple include guards to all of GCC's internal
| headers have been submitted in the past, but never approved and
| applied, probably because they'd need an OK from someone with global
| write privileges and all those people were too busy to review the
| patch.
| 
| It was agreed, last time this came up, that in principle they should
| all have guards.

Thanks for the reminder.  Do you have references to those patches?
I realized that we're in stage 3, so maybe those patches are
inappropriate at this moment; but I think they should be queued for
after mainline is unfrozen.

-- Gaby

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tree.h vs include guard
  2002-08-26  2:22   ` Gabriel Dos Reis
@ 2002-08-29 16:48     ` Zack Weinberg
  2002-08-29 17:34       ` Richard Henderson
  0 siblings, 1 reply; 9+ messages in thread
From: Zack Weinberg @ 2002-08-29 16:48 UTC (permalink / raw)
  To: Gabriel Dos Reis; +Cc: gcc

On Mon, Aug 26, 2002 at 11:17:33AM +0200, Gabriel Dos Reis wrote:
> Zack Weinberg <zack@codesourcery.com> writes:
> 
> | On Wed, Aug 14, 2002 at 02:54:29AM +0200, Gabriel Dos Reis wrote:
> | > 
> | > Hi,
> | > 
> | >   I noticed that tree.h has no guard to prevent multiple-inclusions.
> | > Why so?  FWIW, c-tree.h, c-common.h and cp-tree.h do have such a
> | > thing.
> | 
> | Patches to add multiple include guards to all of GCC's internal
> | headers have been submitted in the past, but never approved and
> | applied, probably because they'd need an OK from someone with global
> | write privileges and all those people were too busy to review the
> | patch.
> | 
> | It was agreed, last time this came up, that in principle they should
> | all have guards.
> 
> Thanks for the reminder.  Do you have references to those patches?
> I realized that we're in stage 3, so maybe those patches are
> inappropriate at this moment; but I think they should be queued for
> after mainline is unfrozen.

http://gcc.gnu.org/ml/gcc-patches/2001-02/msg01342.html and followups.
This is something that could go on the gcc-3_4-basic-improvements-branch,
if we could get review for it.  The patches need updating.

zw

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tree.h vs include guard
  2002-08-29 16:48     ` Zack Weinberg
@ 2002-08-29 17:34       ` Richard Henderson
  0 siblings, 0 replies; 9+ messages in thread
From: Richard Henderson @ 2002-08-29 17:34 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: Gabriel Dos Reis, gcc

On Thu, Aug 29, 2002 at 04:48:02PM -0700, Zack Weinberg wrote:
> http://gcc.gnu.org/ml/gcc-patches/2001-02/msg01342.html and followups.
> This is something that could go on the gcc-3_4-basic-improvements-branch,
> if we could get review for it.  The patches need updating.

If the quoted patch gets its underscores fixed, it's approved.


r~

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tree.h vs include guard
  2002-08-13 20:08 Stan Shebs
  2002-08-13 20:31 ` Gabriel Dos Reis
@ 2002-08-13 23:29 ` Neil Booth
  1 sibling, 0 replies; 9+ messages in thread
From: Neil Booth @ 2002-08-13 23:29 UTC (permalink / raw)
  To: Stan Shebs; +Cc: Devang Patel, Gabriel Dos Reis, gcc

Stan Shebs wrote:-

> 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.
> 
> Stan

CPP avoids caching a file if it has include guards, assuming that it's
unlikely it will be relevant again (because of the MI optimization).
So even unnecessary include guards save a bit of memory usage by the compiler.

Neil.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tree.h vs include guard
  2002-08-13 20:08 Stan Shebs
@ 2002-08-13 20:31 ` Gabriel Dos Reis
  2002-08-13 23:29 ` Neil Booth
  1 sibling, 0 replies; 9+ messages in thread
From: Gabriel Dos Reis @ 2002-08-13 20:31 UTC (permalink / raw)
  To: Stan Shebs; +Cc: Devang Patel, gcc

Stan Shebs <shebs@apple.com> 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: tree.h vs include guard
@ 2002-08-13 20:08 Stan Shebs
  2002-08-13 20:31 ` Gabriel Dos Reis
  2002-08-13 23:29 ` Neil Booth
  0 siblings, 2 replies; 9+ messages in thread
From: Stan Shebs @ 2002-08-13 20:08 UTC (permalink / raw)
  To: Devang Patel; +Cc: Gabriel Dos Reis, gcc

Devang Patel wrote:

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-08-29 17:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-13 17:57 tree.h vs include guard Gabriel Dos Reis
2002-08-13 19:21 ` Devang Patel
2002-08-26  0:18 ` Zack Weinberg
2002-08-26  2:22   ` Gabriel Dos Reis
2002-08-29 16:48     ` Zack Weinberg
2002-08-29 17:34       ` Richard Henderson
2002-08-13 20:08 Stan Shebs
2002-08-13 20:31 ` Gabriel Dos Reis
2002-08-13 23:29 ` Neil Booth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).