From af3f7acfe7b1dc46d5c1d8027863dfa86ce062c9 Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Tue, 29 Jul 2025 08:40:57 +0200 Subject: [PATCH] Explicitly const_cast string literal for C API The implicit conversion form sting literal to char* for C compatibility was removed with C++11, seems MSVC caught up with this in C++20. Use explicit cast instead where needed and change API to const char* otherwise. Signed-off-by: Ralph Sennhauser --- source/lib/sysdep/os/win/tests/test_wdbg_sym.h | 4 ++-- source/lib/sysdep/os/win/wposix/wdlfcn.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/lib/sysdep/os/win/tests/test_wdbg_sym.h b/source/lib/sysdep/os/win/tests/test_wdbg_sym.h index 733abe5afe..79477dbb44 100644 --- a/source/lib/sysdep/os/win/tests/test_wdbg_sym.h +++ b/source/lib/sysdep/os/win/tests/test_wdbg_sym.h @@ -236,7 +236,7 @@ class TestWdbgSym : public CxxTest::TestSuite // also exercises all basic types because we need to display some values // anyway (to see at a glance whether symbol engine addrs are correct) static void m_test_addrs([[maybe_unused]] int p_int, [[maybe_unused]] double p_double, - [[maybe_unused]] char* p_pchar, [[maybe_unused]] uintptr_t p_uintptr) + [[maybe_unused]] const char* p_pchar, [[maybe_unused]] uintptr_t p_uintptr) { [[maybe_unused]] size_t l_uint = 0x1234; [[maybe_unused]] bool l_bool = true; @@ -247,7 +247,7 @@ class TestWdbgSym : public CxxTest::TestSuite static double s_double = -2.718; static char s_chars[] = {'c','h','a','r','s',0}; - static void (*s_funcptr)(int, double, char*, uintptr_t) = m_test_addrs; + static void (*s_funcptr)(int, double, const char*, uintptr_t) = m_test_addrs; static void* s_ptr = (void*)(uintptr_t)0x87654321; static HDC s_hdc = (HDC)0xff0; diff --git a/source/lib/sysdep/os/win/wposix/wdlfcn.cpp b/source/lib/sysdep/os/win/wposix/wdlfcn.cpp index 6f9fc9ef6d..a04a3b0817 100644 --- a/source/lib/sysdep/os/win/wposix/wdlfcn.cpp +++ b/source/lib/sysdep/os/win/wposix/wdlfcn.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -52,11 +52,11 @@ char* dlerror() switch(GetLastError()) { case ERROR_MOD_NOT_FOUND: - return "module not found"; + return const_cast("module not found"); case ERROR_PROC_NOT_FOUND: - return "symbol not found"; + return const_cast("symbol not found"); default: - return "unknown"; + return const_cast("unknown"); } }