From 00b92f42b69af29a820b46049fd00be9cd3fb7d4 Mon Sep 17 00:00:00 2001 From: MKCKR <26296627+mkckr0@users.noreply.github.com> Date: Tue, 16 Feb 2021 13:26:44 +0800 Subject: [PATCH] fix compile error in VS2012 in evutil_gettimeofday() Move static variable definition before other statement, to prevent compile error in VS2012. Fixes: #1135 --- evutil_time.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/evutil_time.c b/evutil_time.c index c3272182..514f2c8a 100644 --- a/evutil_time.c +++ b/evutil_time.c @@ -71,6 +71,9 @@ typedef void (WINAPI *GetSystemTimePreciseAsFileTime_fn_t) (LPFILETIME); int evutil_gettimeofday(struct timeval *tv, struct timezone *tz) { + static GetSystemTimePreciseAsFileTime_fn_t GetSystemTimePreciseAsFileTime_fn = NULL; + static int check_precise = 1; + #ifdef _MSC_VER #define U64_LITERAL(n) n##ui64 #else @@ -93,9 +96,6 @@ evutil_gettimeofday(struct timeval *tv, struct timezone *tz) if (tv == NULL) return -1; - static GetSystemTimePreciseAsFileTime_fn_t GetSystemTimePreciseAsFileTime_fn = NULL; - static int check_precise = 1; - if (EVUTIL_UNLIKELY(check_precise)) { HMODULE h = evutil_load_windows_system_library_(TEXT("kernel32.dll")); if (h != NULL) -- 2.50.1