diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index dfa9c0699d..0d7b72d6be 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -1919,7 +1919,7 @@ static uint64_t frontend_linux_get_mem_total(void) char line[256]; uint64_t total = 0; while (fgets(line, sizeof(line), data)) { - if (sscanf(line, "MemTotal: %lu kB", &total) == 1) { + if (sscanf(line, "MemTotal: " STRING_REP_ULONG " kB", &total) == 1) { fclose(data); total *= 1024; return total; @@ -1942,14 +1942,15 @@ static uint64_t frontend_linux_get_mem_used(void) uint64_t cached = 0; char line[256]; - while (fgets(line, sizeof(line), data)) { - if (sscanf(line, "MemTotal: %lu kB", &total) == 1) + while (fgets(line, sizeof(line), data)) + { + if (sscanf(line, "MemTotal: " STRING_REP_ULONG " kB", &total) == 1) total *= 1024; - if (sscanf(line, "MemFree: %lu kB", &freemem) == 1) + if (sscanf(line, "MemFree: " STRING_REP_ULONG " kB", &freemem) == 1) freemem *= 1024; - if (sscanf(line, "Buffers: %lu kB", &buffers) == 1) + if (sscanf(line, "Buffers: " STRING_REP_ULONG " kB", &buffers) == 1) buffers *= 1024; - if (sscanf(line, "Cached: %lu kB", &cached) == 1) + if (sscanf(line, "Cached: " STRING_REP_ULONG " kB", &cached) == 1) cached *= 1024; } diff --git a/libretro-common/include/retro_common_api.h b/libretro-common/include/retro_common_api.h index 46bce17e7b..b82b2195a8 100644 --- a/libretro-common/include/retro_common_api.h +++ b/libretro-common/include/retro_common_api.h @@ -75,6 +75,14 @@ typedef int ssize_t; #include #endif +#ifdef _WIN32 +#define STRING_REP_ULONG "%Iu" +#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L +#define STRING_REP_ULONG "%zu" +#else +#define STRING_REP_ULONG "%lu" +#endif + /* I would like to see retro_inline.h moved in here; possibly boolean too. diff --git a/tasks/task_database.c b/tasks/task_database.c index 80f2026ddb..2a6cd925e8 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -85,28 +85,17 @@ static int task_database_iterate_start(database_info_handle_t *db, { char msg[128] = {0}; -#ifdef _WIN32 snprintf(msg, sizeof(msg), - "%Iu/%Iu: %s %s...\n", + STRING_REP_ULONG "/" STRING_REP_ULONG ": %s %s...\n", +#if defined(_WIN32) || defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L db->list_ptr, db->list->size, - msg_hash_to_str(MSG_SCANNING), - name); -#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L - snprintf(msg, sizeof(msg), - "%zu/%zu: %s %s...\n", - db->list_ptr, - db->list->size, - msg_hash_to_str(MSG_SCANNING), - name); #else - snprintf(msg, sizeof(msg), - "%lu/%lu: %s %s...\n", (unsigned long)db->list_ptr, (unsigned long)db->list->size, +#endif msg_hash_to_str(MSG_SCANNING), name); -#endif if (!string_is_empty(msg)) runloop_msg_queue_push(msg, 1, 180, true);