From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 15/16] gdb: remove redundant snprintf declaration check
Date: Tue, 13 Oct 2026 11:36:01 -0400 [thread overview]
Message-ID: <20261013153657.1610298-16-simon.marchi@efficios.com> (raw)
In-Reply-To: <20261013153657.1610298-1-simon.marchi@efficios.com>
configure.ac checks for the snprintf declaration, but libiberty_INIT
already does it. Remove the check from configure.ac.
The only user of HAVE_DECL_SNPRINTF in GDB is a check in
python-internal.h, which defines HAVE_SNPRINTF on Windows, to prevent
older Python headers from redefining snprintf to _snprintf. It uses
"defined (HAVE_DECL_SNPRINTF)", which is always true, since
AC_CHECK_DECLS defines HAVE_DECL_SNPRINTF to either 0 or 1. Since it
apparently worked fine like this for a while, simplify the condition to
just check _WIN32. snprintf is standard in C++11 anyway.
I checked whether defining HAVE_SNPRINTF is still needed at all. It is
no longer necessary since CPython commit e822e37946f2 ("bpo-36020:
Remove snprintf macro in pyerrors.h (GH-20889)", 2020-06-15), which is
available since Python 3.9. So once we drop support for Python 3.8 and
below, this can go. Add a note in the source about that.
Regenerate configure.
Change-Id: I431ccdf7d67a673c8a01ba4f34378a040a4c7bc6
---
gdb/configure | 11 -----------
gdb/configure.ac | 1 -
gdb/python/python-internal.h | 7 +++++--
3 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/gdb/configure b/gdb/configure
index 5290d29efbce..cfe994c3842a 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -29426,17 +29426,6 @@ _ACEOF
-ac_fn_c_check_decl "$LINENO" "snprintf" "ac_cv_have_decl_snprintf" "$ac_includes_default"
-if test "x$ac_cv_have_decl_snprintf" = xyes; then :
- ac_have_decl=1
-else
- ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_SNPRINTF $ac_have_decl
-_ACEOF
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LC_MESSAGES" >&5
$as_echo_n "checking for LC_MESSAGES... " >&6; }
diff --git a/gdb/configure.ac b/gdb/configure.ac
index b1e0a82b9b07..d10b20f5a17d 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1488,7 +1488,6 @@ AC_CHECK_HEADERS([execinfo.h])
libiberty_INIT
-AC_CHECK_DECLS([snprintf])
AM_LC_MESSAGES
# ------------------ #
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 5f023b0d9719..5af06d02a51a 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -39,8 +39,11 @@
around technique as above. */
#undef _FILE_OFFSET_BITS
-/* A kludge to avoid redefinition of snprintf on Windows by pyerrors.h. */
-#if defined(_WIN32) && defined(HAVE_DECL_SNPRINTF)
+/* A kludge to avoid redefinition of snprintf on Windows by pyerrors.h.
+
+ This is only needed for Python <= 3.8, so it can go once support for those
+ Python versions is dropped. */
+#ifdef _WIN32
#define HAVE_SNPRINTF 1
#endif
--
2.56.0
next prev parent reply other threads:[~2026-10-13 15:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 15:35 [PATCH 00/16] Cleanup obsolete configure checks Simon Marchi
2026-10-13 15:35 ` [PATCH 01/16] gdb: don't check for sys/debugreg.h Simon Marchi
2026-10-13 15:35 ` [PATCH 02/16] gdb: don't check for sigsetmask and ttrace Simon Marchi
2026-10-13 15:35 ` [PATCH 03/16] gdbsupport: don't check for strstr declaration Simon Marchi
2026-10-13 15:35 ` [PATCH 04/16] gdbserver, gdbsupport: remove unneeded sys/procfs.h type checks Simon Marchi
2026-10-13 15:35 ` [PATCH 05/16] gdbserver: don't define HAVE_SYNC_BUILTINS Simon Marchi
2026-10-13 15:35 ` [PATCH 06/16] gdb: don't check for long double support Simon Marchi
2026-10-13 15:35 ` [PATCH 07/16] gdbserver: remove leftover Windows CE check in configure.ac Simon Marchi
2026-10-13 15:35 ` [PATCH 08/16] gdbsupport: don't check for memory.h Simon Marchi
2026-10-13 15:35 ` [PATCH 09/16] gdbserver: don't check for string.h Simon Marchi
2026-10-13 15:35 ` [PATCH 10/16] gdb, gdbserver: remove configure checks already done by GDB_AC_COMMON Simon Marchi
2026-10-13 15:35 ` [PATCH 11/16] gdb: remove redundant dlopen library search Simon Marchi
2026-10-13 15:35 ` [PATCH 12/16] gdb: don't check for long long support in the compiler Simon Marchi
2026-10-13 15:35 ` [PATCH 13/16] gdb: remove AC_C_CONST and AC_C_INLINE Simon Marchi
2026-10-13 15:36 ` [PATCH 14/16] gdbserver: remove fallback declarations of perror, vasprintf and vsnprintf Simon Marchi
2026-10-13 15:36 ` Simon Marchi [this message]
2026-10-13 15:36 ` [PATCH 16/16] gdbserver, gdbsupport: don't check for signal.h, fcntl.h and locale.h Simon Marchi
2026-10-14 12:08 ` [PATCH 00/16] Cleanup obsolete configure checks Tom Tromey
2026-10-14 12:53 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261013153657.1610298-16-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox