public inbox for [email protected]
help / color / mirror / Atom feedFrom: Bertrand Drouvot <[email protected]>
Subject: [PATCH v1 2/2] Enable -Wstrict-prototypes and -Wold-style-definition by default
Date: Mon, 9 Mar 2026 09:31:22 +0000
Those are available in all gcc and clang versions that support C11 and as C11
is required as of f5e0186f865c, then we can add them without capability test.
Having them enabled by default avoid having to chase these manually like
11171fe1fc8, cdf4b9aff2, 0e72b9d440, 7069dbcc31, f1283ed6cc, 7b66e2c086,
e95126cf04 and 9f7c527af3 have done.
Also, readline headers trigger a lot of warnings with -Wstrict-prototypes, so
we make use of the system_header pragma to hide the warnings.
Author: Bertrand Drouvot <[email protected]>
Discussion: https://postgr.es/m/13d51b20-a69c-4ac1-8546-ec4fc278064f%40eisentraut.org
Discussion: https://postgr.es/m/aTFctZwWSpl2/LG5%40ip-10-97-1-34.eu-west-3.compute.internal
---
configure | 8 ++++++++
configure.ac | 8 ++++++++
meson.build | 2 ++
src/bin/psql/input.h | 9 +++++++++
4 files changed, 27 insertions(+)
24.8% src/bin/psql/
diff --git a/configure b/configure
index 42621ecd051..dda8217e808 100755
--- a/configure
+++ b/configure
@@ -16905,6 +16905,14 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
fi
+# These flags are supported in all C11-capable GCC/Clang versions,
+# so no capability test is needed. Added here to avoid affecting configure probes,
+# particularly PGAC_PRINTF_ARCHETYPE which uses -Werror and would fail to detect
+# gnu_printf if -Wstrict-prototypes is active.
+if test "$GCC" = yes -a "$ICC" = no; then
+ CFLAGS="$CFLAGS -Wstrict-prototypes -Wold-style-definition"
+fi
+
# --------------------
# Run tests below here
# --------------------
diff --git a/configure.ac b/configure.ac
index 61ec895d23c..98d0698e4c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2032,6 +2032,14 @@ related to locating shared libraries. Check the file 'config.log'
for the exact reason.]])],
[AC_MSG_RESULT([cross-compiling])])
+# These flags are supported in all C11-capable GCC/Clang versions,
+# so no capability test is needed. Added here to avoid affecting configure probes,
+# particularly PGAC_PRINTF_ARCHETYPE which uses -Werror and would fail to detect
+# gnu_printf if -Wstrict-prototypes is active.
+if test "$GCC" = yes -a "$ICC" = no; then
+ CFLAGS="$CFLAGS -Wstrict-prototypes -Wold-style-definition"
+fi
+
# --------------------
# Run tests below here
# --------------------
diff --git a/meson.build b/meson.build
index 2df54409ca6..db3a3327cb5 100644
--- a/meson.build
+++ b/meson.build
@@ -2242,6 +2242,8 @@ if cc.has_argument('-Wmissing-variable-declarations')
cflags_no_missing_var_decls += '-Wno-missing-variable-declarations'
endif
+# These are C-only flags, supported in all C11-capable GCC/Clang versions.
+cflags_warn += cc.get_supported_arguments(['-Wstrict-prototypes', '-Wold-style-definition'])
# The following tests want to suppress various unhelpful warnings by adding
# -Wno-foo switches. But gcc won't complain about unrecognized -Wno-foo
diff --git a/src/bin/psql/input.h b/src/bin/psql/input.h
index 09961c84101..2a47166347e 100644
--- a/src/bin/psql/input.h
+++ b/src/bin/psql/input.h
@@ -17,6 +17,15 @@
#ifdef HAVE_LIBREADLINE
#define USE_READLINE 1
+/*
+ * Readline headers trigger a lot of warnings with our preferred compiler flags
+ * (at least -Wstrict-prototypes is known to be problematic). The system_header
+ * pragma hides warnings from within the rest of this file, if supported.
+ */
+#ifdef HAVE_PRAGMA_GCC_SYSTEM_HEADER
+#pragma GCC system_header
+#endif
+
#if defined(HAVE_READLINE_READLINE_H)
#include <readline/readline.h>
#if defined(HAVE_READLINE_HISTORY_H)
--
2.34.1
--xofE7MYp3i9PRJLn--
view thread (18+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH v1 2/2] Enable -Wstrict-prototypes and -Wold-style-definition by default
In-Reply-To: <no-message-id-723151@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox