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 1hsvdQ-0005Yr-Vv for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Jul 2019 20:55:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hsvdP-0007Gn-Io for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Jul 2019 20:55:43 +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 1hsvdP-0007A3-7y for pgsql-hackers@lists.postgresql.org; Wed, 31 Jul 2019 20:55:43 +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 1hsvdM-0007YJ-8g for pgsql-hackers@postgresql.org; Wed, 31 Jul 2019 20:55:42 +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 x6VKtVvQ022390; Wed, 31 Jul 2019 16:55:32 -0400 From: Tom Lane To: Alvaro Herrera cc: Andres Freund , vignesh C , Pg Hackers Subject: Re: Unused header file inclusion In-reply-to: <20190731203607.GA5260@alvherre.pgsql> References: <20190731203607.GA5260@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Wed, 31 Jul 2019 16:36:07 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <22388.1564606531.1@sss.pgh.pa.us> Date: Wed, 31 Jul 2019 16:55:31 -0400 Message-ID: <22389.1564606531@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > On 2019-Jul-31, Andres Freund wrote: >> * I think a lot of the interlinking stems from the bad idea to use >> typedef's everywhere. In contrast to structs they cannot be forward >> declared portably in our version of C. We should use a lot more struct >> forward declarations, and just not use the typedef. > I don't know about that ... I think the problem is that we both declare > the typedef *and* define the struct in the same place. If we were to > split those things to separate files, the required rebuilds would be > much less, I think, because changing a struct would no longer require > recompiles of files that merely pass those structs around (that's very > common for Node-derived structs). Forward-declaring structs in > unrelated header files just because they need them, feels a bit like > cheating to me. Yeah. I seem to recall a proposal that nodes.h should contain typedef struct Foo Foo; for every node type Foo, and then the other headers would just fill in the structs, and we could get rid of a lot of ad-hoc forward struct declarations and other hackery. regards, tom lane