]> granicus.if.org Git - libevent/commitdiff
fix compile error in VS2012 in evutil_gettimeofday()
authorMKCKR <26296627+mkckr0@users.noreply.github.com>
Tue, 16 Feb 2021 05:26:44 +0000 (13:26 +0800)
committerAzat Khuzhin <azat@libevent.org>
Tue, 16 Feb 2021 22:11:07 +0000 (01:11 +0300)
Move static variable definition before other statement, to prevent
compile error in VS2012.

Fixes: #1135
evutil_time.c

index c327218227a45c97d057c3efc50209302ed9eab1..514f2c8a77d4095d2c80ac1483d3d4f59b74ab58 100644 (file)
@@ -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)