Re: C++ Headers - Mailing list pgsql-hackers

From Christof Petig
Subject Re: C++ Headers
Date
Msg-id 3B08D94D.AE828050@petig-baender.de
Whole thread Raw
In response to Re: C++ Headers  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: C++ Headers
List pgsql-hackers
Tom Lane wrote:

> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > The only mention I see of this is in c.h:
>
> >       #ifndef __cplusplus
> >       #ifndef bool
> >       typedef char bool;
>
> >       #endif   /* ndef bool */
> >       #endif   /* not C++ */
>
> > If you need more cplusplus stuff, lets figure it out and add it.
>
> Actually, that portion of c.h is a time bomb that is likely to blow up
> in the face of some poor C++ user.  There's no guarantee that a C++
> compiler's built-in bool type will be compatible with "char", is there?
> If it happened to be, say, same size as "int", then a C++ module
> would interpret lots of things differently from a C module.

This in fact has happened within ECPG. But since sizeof(bool) is passed to
libecpg it was possible to figure out which 'bool' is requested.

Another issue of C++ compatibility would be cleaning up the usage of
'const' declarations. C++ is really strict about 'const'ness. But I don't
know whether postgres' internal headers would need such a cleanup. (I
suspect that in ecpg there is an oddity left with respect to host variable
declaration. I'll check that later)
   Christof




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Plans for solving the VACUUM problem
Next
From: Patrick Welche
Date:
Subject: Re: cvs snapshot compile problems