]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
headerscheck: Avoid mutual inclusion of pg_config.h and c.h
authorPeter Eisentraut <peter@eisentraut.org>
Mon, 30 Mar 2026 07:31:08 +0000 (09:31 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Mon, 30 Mar 2026 08:14:41 +0000 (10:14 +0200)
Headers that c.h includes early should not have another header
included before them in the headerscheck test file, especially not
c.h.

A particular instance of a problem is that pg_config.h defines some
symbols that c.h later undefines in some cases, such as in the code
added by commit cd083b54bd67, but there were also some before that.
This only works correctly if pg_config.h is included first.

pg_config_manual.h and pg_config_os.h are closely related to
pg_config.h and should be treated the same way.

postgres_ext.h is meant to be usable standalone, so testing it with
c.h included first defeats the point.

c.h also includes port.h, but this commit leaves that alone, since
port.h does need some of c.h to be processed first.  (But because of
header guards, testing port.h separately is probably ineffective.)

Discussion: https://www.postgresql.org/message-id/flat/579116be-5016-4dbc-aed0-c06f8d9f5bbb%40eisentraut.org

src/tools/pginclude/headerscheck

index e75661cc772be86f10c149d5a2e74436d59b7e67..14c466cc237a55fcd700d416227439397e60ac00 100755 (executable)
@@ -213,11 +213,16 @@ do
            # info to guess which, but in some subdirectories there's a
            # reasonable choice to make, and otherwise we use postgres.h.
            # Also, those three files should compile with no pre-include, as
-           # should src/interfaces headers meant to be exposed to clients.
+           # should files included early by c.h, as well as
+           # src/interfaces headers meant to be exposed to clients.
            case "$f" in
+               src/include/c.h) ;;
+               src/include/pg_config.h) ;;
+               src/include/pg_config_manual.h) ;;
+               src/include/pg_config_os.h) ;;
                src/include/postgres.h) ;;
+               src/include/postgres_ext.h) ;;
                src/include/postgres_fe.h) ;;
-               src/include/c.h) ;;
                src/interfaces/libpq/libpq-fe.h) ;;
                src/interfaces/libpq/libpq-events.h) ;;
                src/interfaces/ecpg/ecpglib/ecpglib_extern.h)