1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-24 09:27:52 +03:00

Use stdbool.h if suitable

Using the standard bool type provided by C allows some recent compilers
and debuggers to give better diagnostics.  Also, some extension code and
third-party headers are increasingly pulling in stdbool.h, so it's
probably saner if everyone uses the same definition.

But PostgreSQL code is not prepared to handle bool of a size other than
1, so we keep our own old definition if we encounter a stdbool.h with a
bool of a different size.  (Among current build farm members, this only
applies to old macOS versions on PowerPC.)

To check that the used bool is of the right size, add a static
assertions about size of GinTernaryValue vs bool.  This is currently the
only place that assumes that bool and char are of the same size.

Discussion: https://www.postgresql.org/message-id/flat/3a0fe7e1-5ed1-414b-9230-53bbc0ed1f49@2ndquadrant.com
This commit is contained in:
Peter Eisentraut
2018-03-22 20:42:25 -04:00
parent 2a0faed9d7
commit 9a95a77d9d
5 changed files with 31 additions and 10 deletions

View File

@@ -51,8 +51,8 @@ typedef struct GinStatsData
/*
* A ternary value used by tri-consistent functions.
*
* For convenience, this is compatible with booleans. A boolean can be
* safely cast to a GinTernaryValue.
* This must be of the same size as a bool because some code will cast a
* pointer to a bool to a pointer to a GinTernaryValue.
*/
typedef char GinTernaryValue;