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

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Leandro Fanzone <leandro(at)hasar(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: C++ and bool constants (was Re: [NOVICE] gcc 3.0.1)
Date: 2001-08-26 16:49:22
Message-ID: 200108261649.f7QGnMf12560@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-novice


I like the change.

> 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Larry Rosenman 2001-08-26 17:48:11 Re: Re: [PATCHES] Makefile.PL for Pg.so
Previous Message Tom Lane 2001-08-26 16:11:25 Re: Re: [PATCHES] Makefile.PL for Pg.so

Browse pgsql-novice by date

  From Date Subject
Next Message Leandro Fanzone 2001-08-27 12:49:23 Re: C++ and bool constants (was Re: [NOVICE] gcc 3.0.1)
Previous Message Justin Clift 2001-08-26 07:25:00 New FAQ : FAQ: Working with Dates and Times in PostgreSQL