Hi,
On Wed, Dec 03, 2025 at 11:32:10PM -0500, Tom Lane wrote:
> Bertrand Drouvot <bertranddrouvot.pg@gmail.com> writes:
> > The buildfarm animal remark makes me think to check with -Wstrict-prototypes
> > and -Wold-style-definition. I just did that and found two more (added in v2
> > attached) that the coccinelle script missed...
>
> I looked into enabling -Wstrict-prototypes on one of my buildfarm
> animals, but the attempt failed because libreadline's headers are
> not clean.
It took me some time to reproduce the errors...
The reason is that gcc/clang treat certain directories (like /usr/include and
/usr/local/include on my system) as "system headers" and suppress warnings from
them, even with -Wsystem-headers.
I finally reproduced the issue by installing readline in /opt/readline/include/:
"
In file included from /opt/readline/include/readline/readline.h:36,
from input.h:21,
from command.c:38:
/opt/readline/include/readline/rltypedefs.h:35:1: error: function declaration isn’t a prototype
[-Werror=strict-prototypes]
35 | typedef int Function () __attribute__ ((deprecated));
| ^~~~~~~
/opt/readline/include/readline/rltypedefs.h:36:1: error: function declaration isn’t a prototype
[-Werror=strict-prototypes]
36 | typedef void VFunction () __attribute__ ((deprecated));
| ^~~~~~~
/opt/readline/include/readline/rltypedefs.h:37:1: error: function declaration isn’t a prototype
[-Werror=strict-prototypes]
37 | typedef char *CPFunction () __attribute__ ((deprecated));
| ^~~~~~~
/opt/readline/include/readline/rltypedefs.h:38:1: error: function declaration isn’t a prototype
[-Werror=strict-prototypes]
38 | typedef char **CPPFunction () __attribute__ ((deprecated));
| ^~~~~~~
/opt/readline/include/readline/readline.h:408:1: error: function declaration isn’t a prototype
[-Werror=strict-prototypes]
408 | extern int rl_message ();
| ^~~~~~
"
This makes me wonder: there might be other headers with similar issues that
we just don't see because they're in "system" directories.
Out of curiosity, where is readline installed on your buildfarm animal?
> It looks like we could silence those warnings by #define'ing
> HAVE_STDARG_H and _FUNCTION_DEF before including the readline
> headers. A quick test says that then the warnings do not appear,
> and psql's regression tests still pass. But it would require
> a good deal more investigation of possible side-effects before
> I'd recommend actually doing that.
Yeah, what about using Pragma Directives instead, like in the attached? I don't
see any errors with those and that looks safer to use as it only suppresses
compiler warnings.
Remark: I've read the comment about "pragma GCC diagnostic" in c.h but I think
it's safe to use for -Wstrict-prototypes (as old enough).
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com