From 452107d3f91fe91f2ed9677f29eed1d131380d3c Mon Sep 17 00:00:00 2001 From: Pinwhell <60289470+pinwhell@users.noreply.github.com> Date: Thu, 15 Jan 2026 01:16:39 -0400 Subject: [PATCH] Avoid redundant declaration of error_number_to_condition with GCC -Wredundant-decls GCC 14+ diagnoses a redundant redeclaration of asio::error::detail::error_number_to_condition(int) when error_code.ipp is included via error_code.hpp prior to the public declaration in error.hpp. Introduce a local guard macro to ensure the forward declaration is emitted only once per translation unit, while preserving existing inclusion paths and behavior. No functional or ABI changes. Fixes builds using -Wredundant-decls -Werror with GCC 14/15. --- include/asio/error.hpp | 5 +++-- include/asio/impl/error_code.ipp | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/asio/error.hpp b/include/asio/error.hpp index 596c9b9860..23e50bb812 100644 --- a/include/asio/error.hpp +++ b/include/asio/error.hpp @@ -357,9 +357,10 @@ inline asio::error_code make_error_code(misc_errors e) // boostify: non-boost code starts here namespace detail { - +#if !defined(ASIO_ERROR_NUMBER_TO_CONDITION_DECLARED) +#define ASIO_ERROR_NUMBER_TO_CONDITION_DECLARED ASIO_DECL std::error_condition error_number_to_condition(int ev); - +#endif } // namespace detail // boostify: non-boost code ends here } // namespace error diff --git a/include/asio/impl/error_code.ipp b/include/asio/impl/error_code.ipp index 69ec24ea17..cfb84dc9f5 100644 --- a/include/asio/impl/error_code.ipp +++ b/include/asio/impl/error_code.ipp @@ -35,7 +35,11 @@ namespace asio { namespace error { namespace detail { + // Forward declaration required when error.hpp has not been included. +#if !defined(ASIO_ERROR_NUMBER_TO_CONDITION_DECLARED) +#define ASIO_ERROR_NUMBER_TO_CONDITION_DECLARED ASIO_DECL std::error_condition error_number_to_condition(int ev); +#endif } // namespace detail } // namespace error