headerscheck warnings with late-model gcc
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Date: 2025-08-05T18:09:47Z
Lists: pgsql-hackers
Attachments
- silence-Wmissing-variable-declarations.patch (text/x-diff) patch
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 'ScanKeywords' [-Wmissing-variable-declarations]
1163 | const ScanKeywordList ScanKeywords = {
| ^~~~~~~~~~~~
In file included from /tmp/headerscheck.xp0AI5/test.c:2:
./src/interfaces/ecpg/test/preproc/strings.h:1:13: warning: no previous declaration for 's1' [-Wmissing-variable-declarations]
1 | char *s1,
| ^~
./src/interfaces/ecpg/test/preproc/strings.h:2:21: warning: no previous declaration for 's2' [-Wmissing-variable-declarations]
2 | *s2,
| ^~
./src/interfaces/ecpg/test/preproc/strings.h:3:21: warning: no previous declaration for 's3' [-Wmissing-variable-declarations]
3 | *s3,
| ^~
./src/interfaces/ecpg/test/preproc/strings.h:4:21: warning: no previous declaration for 's4' [-Wmissing-variable-declarations]
4 | *s4,
| ^~
./src/interfaces/ecpg/test/preproc/strings.h:5:21: warning: no previous declaration for 's5' [-Wmissing-variable-declarations]
5 | *s5,
| ^~
./src/interfaces/ecpg/test/preproc/strings.h:6:21: warning: no previous declaration for 's6' [-Wmissing-variable-declarations]
6 | *s6,
| ^~
./src/interfaces/ecpg/test/preproc/strings.h:7:21: warning: no previous declaration for 's7' [-Wmissing-variable-declarations]
7 | *s7,
| ^~
./src/interfaces/ecpg/test/preproc/strings.h:8:21: warning: no previous declaration 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
Commits
-
Silence -Wmissing-variable-declarations in headerscheck.
- 8722e7965fd2 19 (unreleased) landed
-
headerscheck: Document that --with-llvm is required
- f5d07085822a 19 (unreleased) landed
-
headerscheck: Ignore Windows-specific header
- da0413373c09 19 (unreleased) landed
-
headerscheck: Use ICU_CFLAGS
- 664e0d678965 19 (unreleased) landed
-
Add -Wmissing-variable-declarations to the standard compilation flags
- 66188912566b 18.0 cited