Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ujM6h-006WVG-4r for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Aug 2025 18:09:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ujM6g-00AwIU-1D for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Aug 2025 18:09:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ujM6f-00AwIM-Ns for pgsql-hackers@lists.postgresql.org; Tue, 05 Aug 2025 18:09:49 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ujM6d-000tku-02 for pgsql-hackers@lists.postgresql.org; Tue, 05 Aug 2025 18:09:48 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 575I9lC81127776 for ; Tue, 5 Aug 2025 14:09:47 -0400 From: Tom Lane To: pgsql-hackers@lists.postgresql.org Subject: headerscheck warnings with late-model gcc MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <1127759.1754417375.0@sss.pgh.pa.us> Date: Tue, 05 Aug 2025 14:09:47 -0400 Message-ID: <1127775.1754417387@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1127759.1754417375.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Using gcc 15.1.1 (from Fedora 42) I see these warnings that didn't appear with older gcc: $ src/tools/pginclude/headerscheck In file included from /tmp/headerscheck.xp0AI5/test.c:2: ./src/common/kwlist_d.h:1163:23: warning: no previous declaration for 'Sca= nKeywords' [-Wmissing-variable-declarations] 1163 | const ScanKeywordList ScanKeywords =3D { | ^~~~~~~~~~~~ In file included from /tmp/headerscheck.xp0AI5/test.c:2: ./src/interfaces/ecpg/test/preproc/strings.h:1:13: warning: no previous de= claration for 's1' [-Wmissing-variable-declarations] 1 | char *s1, | ^~ ./src/interfaces/ecpg/test/preproc/strings.h:2:21: warning: no previous de= claration for 's2' [-Wmissing-variable-declarations] 2 | *s2, | ^~ ./src/interfaces/ecpg/test/preproc/strings.h:3:21: warning: no previous de= claration for 's3' [-Wmissing-variable-declarations] 3 | *s3, | ^~ ./src/interfaces/ecpg/test/preproc/strings.h:4:21: warning: no previous de= claration for 's4' [-Wmissing-variable-declarations] 4 | *s4, | ^~ ./src/interfaces/ecpg/test/preproc/strings.h:5:21: warning: no previous de= claration for 's5' [-Wmissing-variable-declarations] 5 | *s5, | ^~ ./src/interfaces/ecpg/test/preproc/strings.h:6:21: warning: no previous de= claration for 's6' [-Wmissing-variable-declarations] 6 | *s6, | ^~ ./src/interfaces/ecpg/test/preproc/strings.h:7:21: warning: no previous de= claration for 's7' [-Wmissing-variable-declarations] 7 | *s7, | ^~ ./src/interfaces/ecpg/test/preproc/strings.h:8:21: warning: no previous de= claration for 's8' [-Wmissing-variable-declarations] 8 | *s8; | ^~ While we could possibly get away with making headerscheck ignore that ecpg test header, it seems unwise to skip kwlist_d.h. So I propose the attached patch, which I've confirmed silences these warnings. Curiously, no such complaints appear with cpluspluscheck (which is using g++ 15.1.1). I don't really understand why not: why would they have turned on -Wmissing-variable-declarations by default for C but not C++? But anyway, since there doesn't seem to be any C++ compatibility issue here, I think it's sufficient to fix this in master and not back-patch. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="silence-Wmissing-variable-declarations.patch"; charset="us-ascii" Content-ID: <1127759.1754417375.2@sss.pgh.pa.us> Content-Description: silence-Wmissing-variable-declarations.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/interfaces/ecpg/test/expected/preproc-strings.c b/src/int= erfaces/ecpg/test/expected/preproc-strings.c index a26817968de..55859b624eb 100644 --- a/src/interfaces/ecpg/test/expected/preproc-strings.c +++ b/src/interfaces/ecpg/test/expected/preproc-strings.c @@ -18,6 +18,16 @@ #line 3 "strings.pgc" /* exec sql begin declare section */ #line 1 "strings.h" +/* This extern silences headerscheck warnings with some gcc versions */ + = + = + = + = + = + = + = + = + = = = @@ -29,7 +39,10 @@ = #line 5 "strings.pgc" = -#line 1 "strings.h" +#line 2 "strings.h" + extern char * s1 , * s2 , * s3 , * s4 , * s5 , * s6 , * s7 , * s8 ; + = +#line 11 "strings.h" char * s1 , * s2 , * s3 , * s4 , * s5 , * s6 , * s7 , * s8 ; /* exec sql end declare section */ #line 5 "strings.pgc" diff --git a/src/interfaces/ecpg/test/preproc/strings.h b/src/interfaces/e= cpg/test/preproc/strings.h index edb5be5339e..71581d6f94a 100644 --- a/src/interfaces/ecpg/test/preproc/strings.h +++ b/src/interfaces/ecpg/test/preproc/strings.h @@ -1,3 +1,13 @@ +/* This extern silences headerscheck warnings with some gcc versions */ +extern char *s1, + *s2, + *s3, + *s4, + *s5, + *s6, + *s7, + *s8; + char *s1, *s2, *s3, diff --git a/src/tools/gen_keywordlist.pl b/src/tools/gen_keywordlist.pl index 6ec83ff33f9..8825b4476ac 100644 --- a/src/tools/gen_keywordlist.pl +++ b/src/tools/gen_keywordlist.pl @@ -169,7 +169,16 @@ printf $kwdef qq|static %s\n|, $f; = # Emit the struct that wraps all this lookup info into one variable. = -printf $kwdef "static " if !$extern; +if ($extern) +{ + # This redundant extern declaration is needed to silence headerscheck + # warnings with some gcc versions. + printf $kwdef "extern const ScanKeywordList %s;\n\n", $varname; +} +else +{ + printf $kwdef "static "; +} printf $kwdef "const ScanKeywordList %s =3D {\n", $varname; printf $kwdef qq|\t%s_kw_string,\n|, $varname; printf $kwdef qq|\t%s_kw_offsets,\n|, $varname; ------- =_aaaaaaaaaa0--