Re: Unused header file inclusion
Alvaro Herrera <alvherre@2ndquadrant.com>
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: vignesh C <vignesh21@gmail.com>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2019-07-31T15:23:22Z
Lists: pgsql-hackers
On 2019-Jul-31, vignesh C wrote: > I noticed that there are many header files being > included which need not be included. Yeah, we have tooling for this already in src/tools/pginclude. It's been used before, and it has wreaked considerable havoc; see "git log --grep pgrminclude". I think doing this sort of cleanup is useful to a point -- as Andres mentions, some includes are somewhat more "important" than others, so judgement is needed in each case. I think removing unnecessary include lines from header files is much more useful than from .c files. However, nowadays even I am not very convinced that that is a very fruitful use of time, since many/most developers use ccache which will reduce the compile times anyway in many cases; and development machines are typically much faster than ten years ago. Also, I think addition of new include lines to existing .c files should be a point worth specific attention in patch review, to avoid breaking reasonable modularity boundaries unnecessarily. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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