Re: Unused header file inclusion
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>,
vignesh C <vignesh21@gmail.com>,
Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2019-07-31T23:25:01Z
Lists: pgsql-hackers
Andres Freund <andres@anarazel.de> writes: > On 2019-07-31 16:55:31 -0400, Tom Lane wrote: >> 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. > That to me just seems objectively worse. Now adding a new struct as a > minor implementation detail of some subsystem doesn't just require > recompiling the relevant files, but just about all of pg. Er, what? This list of typedefs would change exactly when enum NodeTag changes, so AFAICS your objection is bogus. It's true that this proposal doesn't help for structs that aren't Nodes, but my sense is that > 90% of our ad-hoc struct references are for Nodes. > Right now we really have weird dependencies between largely independent > subsystem. Agreed, but I think fixing that will take some actually serious design work. It's not going to mechanically fall out of changing typedef rules. > The only reason the explicit forward declaration is needed in the common > case of a 'struct foo*' parameter is that C has weird visibility rules > about the scope of forward declarations in paramters. Yeah, but there's not much we can do about that, nor is getting rid of typedefs in favor of "struct" going to make it even a little bit better. regards, tom lane
Commits
-
Add fmgr.h include to selfuncs.h.
- 4c01a1110388 13.0 landed
-
Add "headerscheck" script to test header-file compilability under C.
- 55ea10918847 13.0 landed
-
Fix failure-to-compile-standalone in scripts_parallel.h.
- 5f110933e114 13.0 landed
-
Remove fmgr.h includes from headers that don't really need it.
- fb3b098fe884 13.0 landed
-
Don't include utils/array.h from acl.h.
- 6a04d345fd80 13.0 landed
-
Remove redundant prototypes for SQL callable functions.
- 0ae2dc4db2ae 13.0 landed
-
Remove unnecessary #include <limits.h>
- e1f4c481b995 13.0 landed
-
Teach tuplesort.c about "top N" sorting, in which only the first N tuples
- d26559dbf356 8.3.0 cited