net/SocketError: work around -Wvla by defining a constexpr variable
This commit is contained in:
parent
45f8449c72
commit
6825e1144e
|
@ -28,7 +28,7 @@
|
||||||
SocketErrorMessage::SocketErrorMessage(socket_error_t code) noexcept
|
SocketErrorMessage::SocketErrorMessage(socket_error_t code) noexcept
|
||||||
{
|
{
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
wchar_t buffer[std::size(msg)];
|
wchar_t buffer[msg_size];
|
||||||
#else
|
#else
|
||||||
auto *buffer = msg;
|
auto *buffer = msg;
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,7 +37,7 @@ SocketErrorMessage::SocketErrorMessage(socket_error_t code) noexcept
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS |
|
FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||||
FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||||
nullptr, code, 0,
|
nullptr, code, 0,
|
||||||
buffer, std::size(msg), nullptr);
|
buffer, msg_size, nullptr);
|
||||||
if (nbytes == 0) {
|
if (nbytes == 0) {
|
||||||
strcpy(msg, "Unknown error");
|
strcpy(msg, "Unknown error");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -82,7 +82,8 @@ IsSocketErrorClosed(socket_error_t code) noexcept
|
||||||
*/
|
*/
|
||||||
class SocketErrorMessage {
|
class SocketErrorMessage {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
char msg[256];
|
static constexpr unsigned msg_size = 256;
|
||||||
|
char msg[msg_size];
|
||||||
#else
|
#else
|
||||||
const char *const msg;
|
const char *const msg;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue