From: MKCKR <26296627+mkckr0@users.noreply.github.com> Date: Tue, 16 Feb 2021 05:26:44 +0000 (+0800) Subject: fix compile error in VS2012 in evutil_gettimeofday() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=00b92f42b69af29a820b46049fd00be9cd3fb7d4;p=libevent fix compile error in VS2012 in evutil_gettimeofday() Move static variable definition before other statement, to prevent compile error in VS2012. Fixes: #1135 --- 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)