Re: Enable -Wstrict-prototypes and -Wold-style-definition by default
Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2026-03-24T07:16:47Z
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
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Add warning option -Wold-style-declaration
- c73e8ee061ad 19 (unreleased) landed
-
configure: Apply -Werror=vla to C++ as well as C
- 488ab592d9ea 19 (unreleased) landed
-
Enable warning like -Wstrict-prototypes on MSVC as well
- b4a132022444 19 (unreleased) landed
-
Remove compiler warning option -Wendif-labels
- 87e1891c459e 19 (unreleased) landed
-
Disable warnings in system headers in MSVC
- bccfc73acde9 19 (unreleased) landed
-
Fix -Wstrict-prototypes warning in ecpg_init_sqlca() declaration.
- f91b8ff6af91 19 (unreleased) landed