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 1iOSQN-0001v1-Pq for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Oct 2019 20:12: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 1iOSQK-00029F-0Y for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Oct 2019 20:12:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iOSQJ-00028f-Ki for pgsql-hackers@lists.postgresql.org; Sat, 26 Oct 2019 20:12:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iOSQC-0001xb-EW; Sat, 26 Oct 2019 20:12:29 +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 x9QKCKeJ025667; Sat, 26 Oct 2019 16:12:20 -0400 From: Tom Lane To: Andrew Gierth cc: Amit Kapila , PostgreSQL Hackers , Michael Meskes Subject: Re: define bool in pgtypeslib_extern.h In-reply-to: <877e4rmi2y.fsf@news-spur.riddles.org.uk> References: <16583.1572010913@sss.pgh.pa.us> <18578.1572020755@sss.pgh.pa.us> <32373.1572110364@sss.pgh.pa.us> <877e4rmi2y.fsf@news-spur.riddles.org.uk> Comments: In-reply-to Andrew Gierth message dated "Sat, 26 Oct 2019 20:29:03 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25665.1572120740.1@sss.pgh.pa.us> Date: Sat, 26 Oct 2019 16:12:20 -0400 Message-ID: <25666.1572120740@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andrew Gierth writes: > "Tom" == Tom Lane writes: > Tom> I'm inclined to think that we need to make ecpglib.h's > Tom> bool-related definitions exactly match c.h, > I'm wondering whether we should actually go the opposite way and say > that c.h's "bool" definition should be backend only, and that in > frontend code we should define a PG_bool type or something of that ilk > for when we want "PG's 1-byte bool" and otherwise let the platform > define "bool" however it wants. > And we certainly shouldn't be defining "bool" in something that's going > to be included in the user's code the way that ecpglib.h is. The trouble here is the hazard of creating an ABI break, if we modify ecpglib.h in a way that causes its "bool" references to be interpreted differently than they were before. I don't think we want that (although I suspect we have inadvertently caused ABI breaks already on platforms where this matters). In practice, since v11 on every modern platform, the exported ecpglib functions have supposed that "bool" is _Bool, because they were compiled in files that included c.h before ecpglib.h. I assert furthermore that clients might well have included before ecpglib.h and thereby been fully compatible with that. If we start having ecpglib.h include itself, we'll just be eliminating a minor header inclusion order hazard. It's also rather hard to argue that including automatically is really likely to break anything that was including ecpglib.h already, since that file was already usurping those symbols. Except on platforms where sizeof(_Bool) isn't 1, but things are already pretty darn broken there. I think it's possible to construct a counterexample that will fail for *anything* we can do here. I'm not inclined to uglify things like mad to reduce the problem space from 0.1% to 0.01% of use-cases, or whatever the numbers would be in practice. regards, tom lane