From de06eb7a036f2890899f4289adc4f84af3475a37 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 18 Aug 2023 18:53:01 -0700 Subject: Fix conversion and maybe-unused warnings with my_fopen --- common/win_main_utf8.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'common/win_main_utf8.h') diff --git a/common/win_main_utf8.h b/common/win_main_utf8.h index 077af533..81734242 100644 --- a/common/win_main_utf8.h +++ b/common/win_main_utf8.h @@ -20,14 +20,20 @@ #define STATIC_CAST(...) static_cast<__VA_ARGS__> #define REINTERPRET_CAST(...) reinterpret_cast<__VA_ARGS__> +#define MAYBE_UNUSED [[maybe_unused]] #else #define STATIC_CAST(...) (__VA_ARGS__) #define REINTERPRET_CAST(...) (__VA_ARGS__) +#ifdef __GNUC__ +#define MAYBE_UNUSED __attribute__((__unused__)) +#else +#define MAYBE_UNUSED +#endif #endif -static FILE *my_fopen(const char *fname, const char *mode) +MAYBE_UNUSED static FILE *my_fopen(const char *fname, const char *mode) { wchar_t *wname=NULL, *wmode=NULL; int namelen, modelen; @@ -44,10 +50,11 @@ static FILE *my_fopen(const char *fname, const char *mode) } #ifdef __cplusplus - auto strbuf = std::make_unique(static_cast(namelen)+modelen); + auto strbuf = std::make_unique(static_cast(namelen) + + static_cast(modelen)); wname = strbuf.get(); #else - wname = (wchar_t*)calloc(sizeof(wchar_t), (size_t)namelen + modelen); + wname = (wchar_t*)calloc(sizeof(wchar_t), (size_t)namelen + (size_t)modelen); #endif wmode = wname + namelen; MultiByteToWideChar(CP_UTF8, 0, fname, -1, wname, namelen); -- cgit v1.2.3