From ac6c375a4e04f200fa9d92edfd8165df68a2fac1 Mon Sep 17 00:00:00 2001 From: Nytra <14206961+Nytra@users.noreply.github.com> Date: Thu, 25 Sep 2025 13:57:44 +0100 Subject: [PATCH 1/2] Fix build error caused by use of deprecated POSIX name of strdup --- rtmidi_c.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtmidi_c.cpp b/rtmidi_c.cpp index 5ddeffb..4ac00b1 100644 --- a/rtmidi_c.cpp +++ b/rtmidi_c.cpp @@ -417,5 +417,5 @@ static void rtmidi_set_error_msg (RtMidiPtr device, const char *err) if (device->msg) { free (device->msg); } - device->msg = strdup(err); + device->msg = _strdup(err); } From c5dd127f0c11ac6774dc03d5c61c11376ac6996a Mon Sep 17 00:00:00 2001 From: Nytra <14206961+Nytra@users.noreply.github.com> Date: Thu, 25 Sep 2025 14:37:21 +0100 Subject: [PATCH 2/2] Change strdup to _strdup on Windows only --- rtmidi_c.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rtmidi_c.cpp b/rtmidi_c.cpp index 4ac00b1..1c6f8b0 100644 --- a/rtmidi_c.cpp +++ b/rtmidi_c.cpp @@ -3,6 +3,11 @@ #include "rtmidi_c.h" #include "RtMidi.h" +// Fixes build error C4996 on Windows 11 with VS2022 +#ifdef _MSC_VER +#define strdup _strdup +#endif + /* Compile-time assertions that will break if the enums are changed in * the future without synchronizing them properly. If you get (g++) * "error: ‘StaticEnumAssert::StaticEnumAssert() [with bool b = false]’ @@ -417,5 +422,5 @@ static void rtmidi_set_error_msg (RtMidiPtr device, const char *err) if (device->msg) { free (device->msg); } - device->msg = _strdup(err); + device->msg = strdup(err); }