aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-08-18 18:53:01 -0700
committerChris Robinson <[email protected]>2023-08-18 18:53:01 -0700
commitde06eb7a036f2890899f4289adc4f84af3475a37 (patch)
tree3be0661d85e6ba1556c6c4e3ab6e1253fafdeb26 /common
parentbb841f02fb06148bba422e92a9b1a6b46ab3bde3 (diff)
Fix conversion and maybe-unused warnings with my_fopen
Diffstat (limited to 'common')
-rw-r--r--common/win_main_utf8.h13
1 files changed, 10 insertions, 3 deletions
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<wchar_t[]>(static_cast<size_t>(namelen)+modelen);
+ auto strbuf = std::make_unique<wchar_t[]>(static_cast<size_t>(namelen) +
+ static_cast<size_t>(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);