From c9e653fee7f2876295e269a2b7bb67ebd97eb7a6 Mon Sep 17 00:00:00 2001 From: otavepto Date: Thu, 21 Dec 2023 05:33:12 +0200 Subject: [PATCH] use an obnoxious name for the file handle variable used in the PRINT_DEBUG macro to avoid collisions, in the caller has a variable with same name --- dll/common_includes.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/dll/common_includes.h b/dll/common_includes.h index 4beb5728..60aeface 100644 --- a/dll/common_includes.h +++ b/dll/common_includes.h @@ -172,26 +172,26 @@ static inline void reset_LastError() extern const std::string dbg_log_file; extern const std::chrono::time_point startup_counter; #if defined(__WINDOWS__) - #define PRINT_DEBUG(a, ...) do { \ - auto __prnt_dbg_ctr = std::chrono::high_resolution_clock::now(); \ - auto __prnt_dbg_duration = __prnt_dbg_ctr - startup_counter; \ - auto __prnt_dbg_micro = std::chrono::duration_cast>(__prnt_dbg_duration); \ - auto __prnt_dbg_ms = std::chrono::duration_cast>(__prnt_dbg_duration); \ - FILE *t = fopen(dbg_log_file.c_str(), "a"); \ - fprintf(t, "[%llu ms, %llu us] [tid %lu] " a, __prnt_dbg_ms.count(), __prnt_dbg_micro.count(), GetCurrentThreadId(), __VA_ARGS__); \ - fclose(t); \ - WSASetLastError(0); \ + #define PRINT_DEBUG(a, ...) do { \ + auto __prnt_dbg_ctr = std::chrono::high_resolution_clock::now(); \ + auto __prnt_dbg_duration = __prnt_dbg_ctr - startup_counter; \ + auto __prnt_dbg_micro = std::chrono::duration_cast>(__prnt_dbg_duration); \ + auto __prnt_dbg_ms = std::chrono::duration_cast>(__prnt_dbg_duration); \ + auto __prnt_dbg_f = fopen(dbg_log_file.c_str(), "a"); \ + fprintf(__prnt_dbg_f, "[%llu ms, %llu us] [tid %lu] " a, __prnt_dbg_ms.count(), __prnt_dbg_micro.count(), GetCurrentThreadId(), __VA_ARGS__); \ + fclose(__prnt_dbg_f); \ + WSASetLastError(0); \ } while (0) #elif defined(__LINUX__) #include - #define PRINT_DEBUG(a, ...) do { \ - auto __prnt_dbg_ctr = std::chrono::high_resolution_clock::now(); \ - auto __prnt_dbg_duration = __prnt_dbg_ctr - startup_counter; \ - auto __prnt_dbg_micro = std::chrono::duration_cast>(__prnt_dbg_duration); \ - auto __prnt_dbg_ms = std::chrono::duration_cast>(__prnt_dbg_duration); \ - FILE *t = fopen(dbg_log_file.c_str(), "a"); \ - fprintf(t, "[%llu ms, %llu us] [tid %ld] " a, __prnt_dbg_ms.count(), __prnt_dbg_micro.count(), syscall(SYS_gettid), ##__VA_ARGS__); \ - fclose(t); \ + #define PRINT_DEBUG(a, ...) do { \ + auto __prnt_dbg_ctr = std::chrono::high_resolution_clock::now(); \ + auto __prnt_dbg_duration = __prnt_dbg_ctr - startup_counter; \ + auto __prnt_dbg_micro = std::chrono::duration_cast>(__prnt_dbg_duration); \ + auto __prnt_dbg_ms = std::chrono::duration_cast>(__prnt_dbg_duration); \ + auto __prnt_dbg_f = fopen(dbg_log_file.c_str(), "a"); \ + fprintf(__prnt_dbg_f, "[%llu ms, %llu us] [tid %ld] " a, __prnt_dbg_ms.count(), __prnt_dbg_micro.count(), syscall(SYS_gettid), ##__VA_ARGS__); \ + fclose(__prnt_dbg_f); \ } while (0) #endif #else // EMU_RELEASE_BUILD