ocornut / imgui_club

Nice things to use along dear imgui
MIT License
927 stars 108 forks source link

MSYS UCRT64 compatibility #31

Closed bilditup1 closed 5 months ago

bilditup1 commented 2 years ago

When using the UCRT64 environment of MSYS2 to make a build that links to the UCRT, instead of to the old msvcrt, stdio and snprintf() work the way they do in MSVC, and expects the same modifiers. However, _MSC_VER is not defined in the UCRT64 headers, and thus the current guard doesn't work. Checking for _UCRT, which is defined, fixes this. Without this fix, it is necessary to define __USE_MINGW_ANSI_STDIO at compile time so as to switch to its implementation of stdio, or compilation will fail if you set warning flags on (-Wall, -Werror, etc). One could ofc ignore this warning but that seems like a bad plan...

Build error log

ocornut commented 5 months ago

Sorry for my late answer. I have merged this. Thank you.

For reference this is what imgui_internal.h is doing: https://github.com/ocornut/imgui/blob/master/imgui_internal.h#L318

#if defined(_MSC_VER) && !defined(__clang__)
#define IM_PRId64   "I64d"
#define IM_PRIu64   "I64u"
#define IM_PRIX64   "I64X"
#else
#define IM_PRId64   "lld"
#define IM_PRIu64   "llu"
#define IM_PRIX64   "llX"
#endif