libpq-fe.h should compile *entirely* standalone - Mailing list pgsql-hackers

From Tom Lane
Subject libpq-fe.h should compile *entirely* standalone
Date
Msg-id 2488193.1677863247@sss.pgh.pa.us
Whole thread Raw
Responses Re: libpq-fe.h should compile *entirely* standalone  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I realized that headerscheck is failing to enforce $SUBJECT.
This is bad, since we aren't really using libpq-fe.h ourselves
in a way that would ensure that c.h symbols don't creep into it.

We can easily do better, as attached, but I wonder which other
headers should get the same treatment.

            regards, tom lane

diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index abbba7aa63..69897092b2 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -142,7 +142,14 @@ do

     # OK, create .c file to include this .h file.
     {
-        test "$f" != src/include/postgres_fe.h && echo '#include "postgres.h"'
+        # Ideally we'd pre-include only the appropriate one of
+        # postgres.h, postgres_fe.h, or c.h, but we don't have enough
+        # info here to guess what to do in most cases.
+        if test "$f" != src/include/postgres_fe.h -a \
+            "$f" != src/interfaces/libpq/libpq-fe.h
+        then
+        echo '#include "postgres.h"'
+        fi
         echo "#include \"$f\""
     } >$tmp/test.c


pgsql-hackers by date:

Previous
From: Jeroen Vermeulen
Date:
Subject: Re: libpq: PQgetCopyData() and allocation overhead
Next
From: Tom Lane
Date:
Subject: Re: libpq: PQgetCopyData() and allocation overhead