From c16f1b49bc77bfd83f75a4cc62d3a86d79936398 Mon Sep 17 00:00:00 2001 From: Alex_Industrial Date: Fri, 2 Feb 2024 16:04:20 +0300 Subject: [PATCH] windows build fix (https://github.com/zerotier/libzt/issues/263) --- CMakeLists.txt | 1 + include/ZeroTierSockets.h | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24b1d79f..13c0b8a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,6 +92,7 @@ include_directories(${ZTO_SRC_DIR}/osdep) include_directories(${ZTO_SRC_DIR}/ext/libnatpmp) include_directories(${ZTO_SRC_DIR}/ext/prometheus-cpp-lite-1.0/core/include) include_directories(${ZTO_SRC_DIR}/ext/prometheus-cpp-lite-1.0/simpleapi/include) +include_directories(${ZTO_SRC_DIR}/ext/) # libzt include_directories(${PROJ_DIR}/src) include_directories(${PROJ_DIR}/include) diff --git a/include/ZeroTierSockets.h b/include/ZeroTierSockets.h index ba9732ae..5523e8bd 100644 --- a/include/ZeroTierSockets.h +++ b/include/ZeroTierSockets.h @@ -197,7 +197,7 @@ typedef enum { /** * Error variable set after each `zts_*` socket call. Provides additional error context. */ -extern int zts_errno; +extern ZTS_API int zts_errno; typedef enum { /** Operation not permitted */ @@ -1011,15 +1011,19 @@ typedef struct { //----------------------------------------------------------------------------// #if defined(_WIN32) -#ifdef ADD_EXPORTS -#define ZTS_API __declspec(dllexport) + #ifndef ZTS_STATIC + #ifdef ADD_EXPORTS + #define ZTS_API __declspec(dllexport) + #else + #define ZTS_API __declspec(dllimport) + #endif + #else + #define ZTS_API + #endif + #define ZTCALL __cdecl #else -#define ZTS_API __declspec(dllimport) -#endif -#define ZTCALL __cdecl -#else -#define ZTS_API -#define ZTCALL + #define ZTS_API + #define ZTCALL #endif //----------------------------------------------------------------------------//