From 6825e1144edbbc7c3f6cd02ffc50c08a901f08ad Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 22 Sep 2020 20:40:18 +0200 Subject: [PATCH] net/SocketError: work around -Wvla by defining a constexpr variable --- src/net/SocketError.cxx | 4 ++-- src/net/SocketError.hxx | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/net/SocketError.cxx b/src/net/SocketError.cxx index 073dd0f1d..9565d9a0c 100644 --- a/src/net/SocketError.cxx +++ b/src/net/SocketError.cxx @@ -28,7 +28,7 @@ SocketErrorMessage::SocketErrorMessage(socket_error_t code) noexcept { #ifdef _UNICODE - wchar_t buffer[std::size(msg)]; + wchar_t buffer[msg_size]; #else auto *buffer = msg; #endif @@ -37,7 +37,7 @@ SocketErrorMessage::SocketErrorMessage(socket_error_t code) noexcept FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, nullptr, code, 0, - buffer, std::size(msg), nullptr); + buffer, msg_size, nullptr); if (nbytes == 0) { strcpy(msg, "Unknown error"); return; diff --git a/src/net/SocketError.hxx b/src/net/SocketError.hxx index 3fa423202..b8f1bd824 100644 --- a/src/net/SocketError.hxx +++ b/src/net/SocketError.hxx @@ -82,7 +82,8 @@ IsSocketErrorClosed(socket_error_t code) noexcept */ class SocketErrorMessage { #ifdef _WIN32 - char msg[256]; + static constexpr unsigned msg_size = 256; + char msg[msg_size]; #else const char *const msg; #endif