Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iOPix-00049n-C7 for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Oct 2019 17:19:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iOPiu-0003VZ-Ru for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Oct 2019 17:19:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iOPiu-0003VF-Is for pgsql-hackers@lists.postgresql.org; Sat, 26 Oct 2019 17:19:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iOPis-00037C-7l; Sat, 26 Oct 2019 17:19:32 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x9QHJOSn032375; Sat, 26 Oct 2019 13:19:24 -0400 From: Tom Lane To: Amit Kapila cc: PostgreSQL Hackers , Andrew Gierth , Michael Meskes Subject: Re: define bool in pgtypeslib_extern.h In-reply-to: References: <16583.1572010913@sss.pgh.pa.us> <18578.1572020755@sss.pgh.pa.us> Comments: In-reply-to Amit Kapila message dated "Sat, 26 Oct 2019 08:51:14 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <32372.1572110364.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 26 Oct 2019 13:19:24 -0400 Message-ID: <32373.1572110364@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Amit Kapila writes: > On Fri, Oct 25, 2019 at 9:55 PM Tom Lane wrote: >> However, we're not out of the woods, because lookee here in >> ecpglib.h: >> #ifndef bool >> #define bool char >> #endif /* ndef bool */ >> I'm more than slightly surprised that we haven't already seen >> problems due to this conflicting with d26a810eb. > I think it is because it never gets any imports from c.h. On closer inspection, it seems to be just blind luck. For example, if I rearrange the inclusion order in a file using ecpglib.h: diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpg= lib/data.c index 7d2a78a..09944ff 100644 --- a/src/interfaces/ecpg/ecpglib/data.c +++ b/src/interfaces/ecpg/ecpglib/data.c @@ -6,8 +6,8 @@ #include = #include "ecpgerrno.h" -#include "ecpglib.h" #include "ecpglib_extern.h" +#include "ecpglib.h" #include "ecpgtype.h" #include "pgtypes_date.h" #include "pgtypes_interval.h" then on a PPC Mac I get data.c:210: error: conflicting types for 'ecpg_get_data' ecpglib_extern.h:167: error: previous declaration of 'ecpg_get_data' was h= ere It's exactly the same problem as we saw with pgtypeslib_extern.h: header ordering changes affect the meaning of uses of bool, and that's just not acceptable. In this case it's even worse because we're mucking with type definitions in a user-visible header. I'm surprised we've not gotten bug reports about that. Maybe all ECPG users include before they include ecpglib.h, but that doesn't exactly make things worry-free either, because code doing that will think that these functions return _Bool, when the compiled library possibly thinks differently. Probably the only thing saving us is that sizeof(_Bool) is 1 on just about every platform in common use nowadays. I'm inclined to think that we need to make ecpglib.h's bool-related definitions exactly match c.h, which will mean that it has to pull in on most platforms, which will mean adding a control symbol for that to ecpg_config.h. I do not think we should export HAVE_STDBOOL_H and SIZEOF_BOOL there though; probably better to have configure make the choice and export something named like PG_USE_STDBOOL. regards, tom lane