From 1dbd9ca67e9901b0763157dd19fe907322f10948 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 21 May 2024 23:46:06 -0700 Subject: [PATCH 1/2] Windows: add a check for broken legacy environments without timespec_get. If you want to build on Windows use a toolchain that supports modern APIs. This means, for Microsoft, UCRT (Universal C Runtime), which is supported by default on modern Visual Studio. MinGW users may have to go out of their way to enable it. (New -D_UCRT flag or something.) The supported toolchain for building on Windows is Visual Studio. Use of other tool chains is not officially supported or guaranteed to work. YMMV. --- src/platform/windows/CMakeLists.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/platform/windows/CMakeLists.txt b/src/platform/windows/CMakeLists.txt index adf67ebde..10c311319 100644 --- a/src/platform/windows/CMakeLists.txt +++ b/src/platform/windows/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2021 Staysail Systems, Inc. +# Copyright 2024 Staysail Systems, Inc. # # This software is supplied under the terms of the MIT License, a # copy of which should be located in the distribution where this @@ -13,14 +13,16 @@ # the static library unless they also go into the dynamic. if (NNG_PLATFORM_WINDOWS) nng_check_sym(InitializeConditionVariable windows.h NNG_HAVE_CONDVAR) + nng_check_sym(timespec_get time.h NNG_HAVE_TIMESPEC_GET) nng_check_sym(snprintf stdio.h NNG_HAVE_SNPRINTF) - if (NOT NNG_HAVE_CONDVAR OR NOT NNG_HAVE_SNPRINTF) + if (NOT NNG_HAVE_CONDVAR OR NOT NNG_HAVE_SNPRINTF OR NOT NNG_HAVE_TIMESPEC_GET) message(FATAL_ERROR "Modern Windows API support is missing. " "Versions of Windows prior to Vista are not supported. " - "Further, the 32-bit MinGW environment is not supported. " + "Further, the legacy MinGW environments are not supported. " "Ensure you have at least Windows Vista or newer, and are " - "using either Visual Studio 2013 or newer or MinGW-W64.") + "using either Visual Studio 2013 or compatible compiler, " + "and are also using the universal C runtime (UCRT).") endif () nng_link_libraries(ws2_32 mswsock advapi32) @@ -50,4 +52,4 @@ if (NNG_PLATFORM_WINDOWS) nng_test(win_ipc_sec_test) -endif () \ No newline at end of file +endif () From b7a0227a7ed500ee0fc0057345caf624ae90002f Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 21 May 2024 23:52:45 -0700 Subject: [PATCH 2/2] fixes #1825 Compiler warning due to unused variable in win_clock.c --- src/platform/windows/win_clock.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/platform/windows/win_clock.c b/src/platform/windows/win_clock.c index 2beeec459..a51738e50 100644 --- a/src/platform/windows/win_clock.c +++ b/src/platform/windows/win_clock.c @@ -24,7 +24,6 @@ nni_clock(void) int nni_time_get(uint64_t *seconds, uint32_t *nanoseconds) { - int rv; struct timespec ts; if (timespec_get(&ts, TIME_UTC) == TIME_UTC) { *seconds = ts.tv_sec;