Skip to content

Commit 29bf808

Browse files
authored
Cherry pick CCTZ fix for MinGW (#1508)
1 parent d583a59 commit 29bf808

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

absl/time/internal/cctz/src/time_zone_lookup.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@
3939
#include <sdkddkver.h>
4040
// Include only when the SDK is for Windows 10 (and later), and the binary is
4141
// targeted for Windows XP and later.
42-
#if defined(_WIN32_WINNT_WIN10) && (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
42+
// Note: The Windows SDK added windows.globalization.h file for Windows 10, but
43+
// MinGW did not add it until NTDDI_WIN10_NI (SDK version 10.0.22621.0).
44+
#if ((defined(_WIN32_WINNT_WIN10) && !defined(__MINGW32__)) || \
45+
(defined(NTDDI_WIN10_NI) && NTDDI_VERSION >= NTDDI_WIN10_NI)) && \
46+
(_WIN32_WINNT >= _WIN32_WINNT_WINXP)
47+
#define USE_WIN32_LOCAL_TIME_ZONE
4348
#include <roapi.h>
4449
#include <tchar.h>
4550
#include <wchar.h>
@@ -87,7 +92,7 @@ int __system_property_get(const char* name, char* value) {
8792
}
8893
#endif
8994

90-
#if defined(_WIN32_WINNT_WIN10) && (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
95+
#if defined(USE_WIN32_LOCAL_TIME_ZONE)
9196
// Calls the WinRT Calendar.GetTimeZone method to obtain the IANA ID of the
9297
// local time zone. Returns an empty vector in case of an error.
9398
std::string win32_local_time_zone(const HMODULE combase) {
@@ -278,7 +283,7 @@ time_zone local_time_zone() {
278283
zone = primary_tz.c_str();
279284
}
280285
#endif
281-
#if defined(_WIN32_WINNT_WIN10) && (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
286+
#if defined(USE_WIN32_LOCAL_TIME_ZONE)
282287
// Use the WinRT Calendar class to get the local time zone. This feature is
283288
// available on Windows 10 and later. The library is dynamically linked to
284289
// maintain binary compatibility with Windows XP - Windows 7. On Windows 8,

0 commit comments

Comments
 (0)