Re: Enable -Wstrict-prototypes and -Wold-style-definition by default

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Enable -Wstrict-prototypes and -Wold-style-definition by default
Date: 2026-03-24 07:16:47
Message-ID: acI6X6YmtHnEURKL@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Mar 23, 2026 at 04:13:20PM +0100, Peter Eisentraut wrote:
> On 18.03.26 14:32, Peter Eisentraut wrote:
> > On 16.03.26 10:55, Peter Eisentraut wrote:
> > > On 09.03.26 17:39, Bertrand Drouvot wrote:
> > > > 0001: Prevent -Wstrict-prototypes and -Wold-style-definition warnings
> > > >
> > > > It fixes the remaining warnings that those new flags would generate.
> > >
> > > I have committed this one.  I'll look at the rest next.
> >
> > Also committed.
>
> I have a couple of follow-up patches that I had developed while playing with
> this.

Thanks!

> There is a warning option for MSVC that appears to have a very similar
> effect to the ones we added here, so I propose we add that one as well.
>
> Additionally, there is an option for MSVC to disable warnings in system
> headers, similar to the default behavior of GCC. This would be required
> here because some system header files have non-strict prototypes.

Some comments:

0001:

+ '/external:anglebrackets',
+ '/external:W0',

The doc [1], states:

"
The /external compiler options are available starting in Visual Studio 2017 version 15.6.
In versions of Visual Studio before Visual Studio 2019 version 16.10, the /external
options require you also set the /experimental:external compiler option.
"

We currently require MSVC 2019, but what if one is using a version < 16.10?

0003:

"
This has been the default since gcc 4.0. (Introduced in 3.3, so it
was only available but turned off for a relatively short time.)
"

It looks like it was default to on since its introduction in 909de5da19 ([2]),
means since 3.3. In 90689ae11db ([3]), added in 4.0, the documentation has been
updated to mention it (but I think that it was already on by default since
3.3).

0004:

--- a/meson.build
+++ b/meson.build
@@ -2199,6 +2199,7 @@ unroll_loops_cflags = cc.get_supported_arguments(['-funroll-loops'])

common_warning_flags = [
'-Wmissing-prototypes',
+ '-Wold-style-declaration',

Nit, what about adding it with (as the comment is also accurate for the new one)?

"
# These are C-only flags, supported in all C11-capable GCC/Clang versions.
cflags_warn += cc.get_supported_arguments(['-Wstrict-prototypes', '-Wold-style-definition'])
"

[1]: https://learn.microsoft.com/en-us/cpp/build/reference/external-external-headers-diagnostics?view=msvc-170
[2]: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=909de5da192
[3]: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=90689ae11db

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message getiancheng 2026-03-24 07:17:09 Re: bugfix - fix broken output in expanded aligned format, when data are too short
Previous Message Lukas Fittl 2026-03-24 07:16:07 Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc?