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

Поиск
Список
Период
Сортировка
От Leandro Fanzone
Тема Re: C++ and bool constants (was Re: [NOVICE] gcc 3.0.1)
Дата
Msg-id 3B8A41D3.A6BE80A8@hasar.com
обсуждение исходный текст
Ответ на C++ and bool constants (was Re: [NOVICE] gcc 3.0.1)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Fine for me also.

Leandro.

Tom Lane wrote:

> Leandro Fanzone <leandro@hasar.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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: J Smith
Дата:
Сообщение: Re: Link to bug webpage / Bugzilla?
Следующее
От: Juan Manuel García Arias
Дата:
Сообщение: Problem with postgres's date