pgsql: Fix ecpglib.h to declare bool consistently with c.h. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix ecpglib.h to declare bool consistently with c.h.
Date
Msg-id E1iUaSh-0004oe-Cy@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix ecpglib.h to declare bool consistently with c.h.

This completes the task begun in commit 1408d5d86, to synchronize
ECPG's exported definitions with the definition of bool used by
c.h (and, therefore, the one actually in use in the ECPG library).
On practically all modern platforms, ecpglib.h will now just
include <stdbool.h>, which should surprise nobody anymore.
That removes a header-inclusion-order hazard for ECPG clients,
who previously might get build failures or unexpected behavior
depending on whether they'd included <stdbool.h> themselves,
and if so, whether before or after ecpglib.h.

On platforms where sizeof(_Bool) is not 1 (only old PPC-based
Mac systems, as far as I know), things are still messy, as
inclusion of <stdbool.h> could still break ECPG client code.
There doesn't seem to be any clean fix for that, and given the
probably-negligible population of users who would care anymore,
it's not clear we should go far out of our way to cope with it.
This change at least fixes some header-inclusion-order hazards
for our own code, since c.h and ecpglib.h previously disagreed
on whether bool should be char or unsigned char.

To implement this with minimal invasion of ECPG client namespace,
move the choice of whether to rely on <stdbool.h> into configure,
and have it export a configuration symbol PG_USE_STDBOOL.

ecpglib.h no longer exports definitions for TRUE and FALSE,
only their lowercase brethren.  We could undo that if we get
push-back about it.

Ideally we'd back-patch this as far as v11, which is where c.h
started to rely on <stdbool.h>.  But the odds of creating problems
for formerly-working ECPG client code seem about as large as the
odds of fixing any non-working cases, so we'll just do this in HEAD.

Discussion: https://postgr.es/m/CAA4eK1LmaKO7Du9M9Lo=kxGU8sB6aL8fa3sF6z6d5yYYVe3BuQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7a0574b50ee9c2b96ce94c29e031c103285c0b1d

Modified Files
--------------
configure                                    |  6 +++++
configure.in                                 |  7 +++++
src/backend/utils/fmgr/dfmgr.c               |  2 +-
src/include/c.h                              |  9 ++++---
src/include/pg_config.h.in                   |  3 +++
src/include/pg_config.h.win32                |  3 +++
src/interfaces/ecpg/include/ecpg_config.h.in |  3 +++
src/interfaces/ecpg/include/ecpglib.h        | 38 ++++++++++++++++++----------
src/pl/plperl/plperl.h                       |  4 +--
src/tools/msvc/Solution.pm                   |  1 +
10 files changed, 55 insertions(+), 21 deletions(-)


pgsql-committers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: pgsql: Make the order of the header file includes consistent in backend
Next
From: Peter Geoghegan
Date:
Subject: pgsql: Teach datum_image_eq() about cstring datums.