Re: bool: symbol name collision - Mailing list pgsql-bugs

From Peter Eisentraut
Subject Re: bool: symbol name collision
Date
Msg-id 1273423739.16789.2.camel@vanquo.pezone.net
Whole thread Raw
In response to Re: bool: symbol name collision  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: bool: symbol name collision  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: bool: symbol name collision  (bryanh@giraffe-data.com (Bryan Henderson))
List pgsql-bugs
On sön, 2010-05-09 at 11:35 -0400, Tom Lane wrote:
> bryanh@giraffe-data.com (Bryan Henderson) writes:
> > The interface header files for Postgres server extensions define "bool",
> > but that name is commonly used by other parts of user code, including
> > by standards (C99, C++).  That causes, at best, compile failures.
>
> > If Postgres has to define a boolean type in public header files, it should
> > use a name that won't collide, like postgres_bool.
>
> Sorry, this isn't going to happen.  It would break far too much existing
> code, and we consider building server extensions with C++ to be
> unsupported anyway.

Um, our code has

#ifndef __cplusplus

#ifndef bool
typedef char bool;
#endif

#ifndef true
#define true    ((bool) 1)
#endif

etc.

so somehow it was once thought that it is worth supporting other
definitions of bool.  Now to make this work in practice you probably
need to play some games with undefining and redefining and include file
order and so on, but I think it could work.  In any case, it would be
better if Bryan could show us a concrete example that is causing
problems.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #5455: two PGTYPES_NUM_OVERFLOWs
Next
From: Tom Lane
Date:
Subject: Re: bool: symbol name collision