From aebb8bb6d3f792336ec38fc96c368156fe52ceb6 Mon Sep 17 00:00:00 2001 From: Michael Bleis Date: Wed, 1 Mar 2023 11:54:06 +0100 Subject: [PATCH] fix(odr): Fix ODR violation for libuuid symbols Signed-off-by: Michael Bleis --- CMakeLists.txt | 5 +++++ src/WebSocket.c | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf0fd68b..5b687420 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,7 @@ ENDIF() ## build options SET(PAHO_WITH_SSL FALSE CACHE BOOL "Flag that defines whether to build ssl-enabled binaries too. ") +SET(PAHO_WITH_LIBUUID TRUE CACHE BOOL "Flag that defines whether libuuid or a custom uuid implementation should be used") SET(PAHO_BUILD_SHARED TRUE CACHE BOOL "Build shared library") SET(PAHO_BUILD_STATIC FALSE CACHE BOOL "Build static library") SET(PAHO_BUILD_DOCUMENTATION FALSE CACHE BOOL "Create and install the HTML based API documentation (requires Doxygen)") @@ -62,6 +63,10 @@ IF (PAHO_USE_SELECT) ADD_DEFINITIONS(-DUSE_SELECT=1) ENDIF() +IF (PAHO_WITH_LIBUUID) + ADD_DEFINITIONS(-DUSE_LIBUUID=1) +ENDIF() + IF (NOT PAHO_BUILD_SHARED AND NOT PAHO_BUILD_STATIC) MESSAGE(FATAL_ERROR "You must set either PAHO_BUILD_SHARED, PAHO_BUILD_STATIC, or both") ENDIF() diff --git a/src/WebSocket.c b/src/WebSocket.c index 4870f916..c57ae7de 100644 --- a/src/WebSocket.c +++ b/src/WebSocket.c @@ -89,7 +89,7 @@ #define HTTP_PROTOCOL(x) x ? "https" : "http" #if !(defined(_WIN32) || defined(_WIN64)) -#if defined(LIBUUID) +#if defined(USE_LIBUUID) #include #else /* if defined(USE_LIBUUID) */ #include @@ -103,7 +103,7 @@ typedef unsigned char uuid_t[16]; * @brief generates a uuid, compatible with RFC 4122, version 4 (random) * @note Uses a very insecure algorithm but no external dependencies */ -void uuid_generate( uuid_t out ) +static void uuid_generate( uuid_t out ) { #if defined(OPENSSL) int rc = RAND_bytes( out, sizeof(uuid_t)); @@ -121,7 +121,7 @@ void uuid_generate( uuid_t out ) } /** @brief converts a uuid to a string */ -void uuid_unparse( uuid_t uu, char *out ) +static void uuid_unparse( uuid_t uu, char *out ) { int i; for ( i = 0; i < 16; ++i ) @@ -135,7 +135,7 @@ void uuid_unparse( uuid_t uu, char *out ) } *out = '\0'; } -#endif /* else if defined(LIBUUID) */ +#endif /* else if defined(USE_LIBUUID) */ #endif /* if !(defined(_WIN32) || defined(_WIN64)) */ #include "Heap.h"