Add preprocessor check in ZeroTierSockets.h for inclusion of integer definitions. A response to e94ca31.

This commit is contained in:
Joseph Henry
2021-01-04 20:57:18 -08:00
parent 608c81fba6
commit a8c757eaff
2 changed files with 24 additions and 3 deletions

View File

@@ -270,7 +270,12 @@ file (GLOB libminiupnpcSrcGlob
${ZTO_SRC_DIR}/ext/miniupnpc/upnperrors.c ${ZTO_SRC_DIR}/ext/miniupnpc/upnperrors.c
${ZTO_SRC_DIR}/ext/miniupnpc/upnpreplyparse.c) ${ZTO_SRC_DIR}/ext/miniupnpc/upnpreplyparse.c)
file (GLOB libztSrcGlob ${LIBZT_SRC_DIR}/*.cpp) if (ZTS_PINVOKE)
set (ZTS_SWIG_WRAPPER_FILE ${PROJ_DIR}/examples/csharp/*.cxx)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DZTS_PINVOKE=1")
endif ()
file (GLOB libztSrcGlob ${LIBZT_SRC_DIR}/*.cpp ${ZTS_SWIG_WRAPPER_FILE})
if (UNIX) if (UNIX)
set (LWIP_PORT_DIR ${PROJ_DIR}/ext/lwip-contrib/ports/unix/port) set (LWIP_PORT_DIR ${PROJ_DIR}/ext/lwip-contrib/ports/unix/port)
@@ -466,8 +471,13 @@ endif ()
# xcode framework # xcode framework
if (IN_XCODE) if (IN_XCODE)
include_directories (${frameworkHeaderGlob})
# stdint.h is needed for API definitions but can cause conflicts
# in certain projects where integers may already be defined.
# Thus this flag is used to exclude their definition in ZeroTierSockets.h
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DZTS_NO_STDINT_H=1")
include_directories (${frameworkHeaderGlob})
add_library(${XCODE_FRAMEWORK_NAME} STATIC add_library(${XCODE_FRAMEWORK_NAME} STATIC
$<TARGET_OBJECTS:libzt_obj> $<TARGET_OBJECTS:libzt_obj>

View File

@@ -17,6 +17,10 @@
* This defines the external C API for ZeroTier Sockets * This defines the external C API for ZeroTier Sockets
*/ */
#if !ZTS_NO_STDINT_H
#include <stdint.h>
#endif
#ifndef ZT_SOCKETS_H #ifndef ZT_SOCKETS_H
#define ZT_SOCKETS_H #define ZT_SOCKETS_H
@@ -885,7 +889,14 @@ ZTS_API int ZTCALL zts_allow_local_conf(uint8_t allowed);
* @param callback User-specified callback for ZTS_EVENT_* events * @param callback User-specified callback for ZTS_EVENT_* events
* @return ZTS_ERR_OK on success. ZTS_ERR_SERVICE or ZTS_ERR_ARG on failure * @return ZTS_ERR_OK on success. ZTS_ERR_SERVICE or ZTS_ERR_ARG on failure
*/ */
#ifdef ZTS_PINVOKE
// Used by P/INVOKE wrappers
typedef void (*CppCallback)(void *msg);
ZTS_API int ZTCALL zts_start(const char *path, CppCallback callback, uint16_t port);
#else
ZTS_API int ZTCALL zts_start(const char *path, void (*callback)(void *), uint16_t port); ZTS_API int ZTCALL zts_start(const char *path, void (*callback)(void *), uint16_t port);
#endif
/** /**
* @brief Stops the ZeroTier service and brings down all virtual network interfaces * @brief Stops the ZeroTier service and brings down all virtual network interfaces