Fix WidenFilename deprecation warning on MinGW/Windows#2302
Fix WidenFilename deprecation warning on MinGW/Windows#2302cary-ilm wants to merge 2 commits intoAcademySoftwareFoundation:mainfrom
Conversation
Use MultiByteToWideChar(CP_UTF8) on Windows instead of std::wstring_convert/std::codecvt_utf8, which are deprecated in C++17 and trigger -Wdeprecated-declarations on GCC 15 / MinGW. On non-Windows, keep using the deprecated API and suppress the warning with pragmas, since the standard library does not yet provide a replacement. Made with the help of: Cursor / Claude Opus 4.5 Signed-off-by: Cary Phillips <cary@ilm.com>
|
|
||
| #include <codecvt> | ||
| #include <locale> | ||
| #if defined(_WIN32) || defined(_WIN64) |
There was a problem hiding this comment.
No need for _WIN64, simple #ifdef _WIN32 is enough
| std::wstring | ||
| WidenFilename (const char* filename) | ||
| { | ||
| #if defined(_WIN32) || defined(_WIN64) |
| MultiByteToWideChar ( | ||
| CP_UTF8, 0, filename, -1, &result[0], len); | ||
| return result; | ||
| #else |
There was a problem hiding this comment.
Why are wide strings needed on non-Windows platforms at all?
There was a problem hiding this comment.
I'm not entirely sure, but presumably it's to keep the API consistent between Windows and Linux/macOS.
There was a problem hiding this comment.
presumably it's to keep the API consistent between Windows and Linux/macOS
Ok. But is that really required? AFAICT you'd never call WidenFilename outside of Windows anyway? Makes it easier/clear-cut to completely drop in the future potentially IMHO...
Signed-off-by: Cary Phillips <cary@ilm.com>
|
@darbyjohnston, looks like you added the |
|
Looking at my original PR, it looks like the Hmm, poking around some more there is also a version in If you don't mind a bit of code duplication we could remove 'WidenFilename' and replace it with |
At the same time |
|
Replaced with #2314 |
This fixes the warning:
Use MultiByteToWideChar(CP_UTF8) on Windows instead of std::wstring_convert/std::codecvt_utf8, which are deprecated in C++17 and trigger -Wdeprecated-declarations on GCC 15 / MinGW.
On non-Windows, keep using the deprecated API and suppress the warning with pragmas, since the standard library does not yet provide a replacement.
Made with the help of: Cursor / Claude Opus 4.5