Skip site navigation (1) Skip section navigation (2)

Re: C++ and bool constants (was Re: [NOVICE] gcc 3.0.1)

From: Leandro Fanzone <leandro(at)hasar(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: C++ and bool constants (was Re: [NOVICE] gcc 3.0.1)
Date: 2001-08-27 12:49:23
Message-ID: 3B8A41D3.A6BE80A8@hasar.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-novice
Fine for me also.

Leandro.

Tom Lane wrote:

> Leandro Fanzone <leandro(at)hasar(dot)com> writes:
> > I have compiled PostgreSQL 7.1.2 with gcc 3.0.1, and have the following
> > problem: if I include first libpq++.h before iostream, id est:
> > #include <libpq++.h>
> > #include <iostream>
> > the compiler complains:
>
> > This is because somewhere in PostgreSQL you have the following code:
>
> > #ifndef true
> > #define true ((bool)1)
> > #endif
>
> Yeah.  c.h has
>
> #ifndef __cplusplus
> #ifndef bool
> typedef char bool;
> #endif   /* ndef bool */
> #endif   /* not C++ */
>
> #ifndef true
> #define true    ((bool) 1)
> #endif
>
> #ifndef false
> #define false   ((bool) 0)
> #endif
>
> It's been like that for quite some time, but it's always struck me as
> bizarre: if we're willing to trust a C++ compiler to provide type
> bool, why would we not trust it to provide the literals true and false
> as well?  ISTM the code should read
>
> #ifndef __cplusplus
>
> #ifndef bool
> typedef char bool;
> #endif
>
> #ifndef true
> #define true    ((bool) 1)
> #endif
>
> #ifndef false
> #define false   ((bool) 0)
> #endif
>
> #endif   /* not C++ */
>
> Does anyone have an objection to this?
>
>                         regards, tom lane


In response to

pgsql-novice by date

Next:From: Marc G. FournierDate: 2001-08-29 15:00:38
Subject: List archives moved and cleaned up ...
Previous:From: Bruce MomjianDate: 2001-08-26 16:49:22
Subject: Re: C++ and bool constants (was Re: [NOVICE] gcc 3.0.1)

pgsql-hackers by date

Next:From: Zeugswetter Andreas SB SDDate: 2001-08-27 15:25:43
Subject: RE: extern + static issue in datetime.c
Previous:From: Oleg BartunovDate: 2001-08-27 11:24:04
Subject: GiST vacation

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group