From 3fbb2a00860f8dd05b68e3edea779c9e80294bbd Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 11 Nov 2023 21:57:25 -0600 Subject: [PATCH] [ox/logconn] MSVC fixes --- deps/ox/src/ox/CMakeLists.txt | 3 +++ deps/ox/src/ox/logconn/CMakeLists.txt | 1 + deps/ox/src/ox/logconn/logconn.cpp | 20 +++++++++++++++++--- deps/ox/src/ox/logconn/logconn.hpp | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/deps/ox/src/ox/CMakeLists.txt b/deps/ox/src/ox/CMakeLists.txt index 4a9985f6..815f2997 100644 --- a/deps/ox/src/ox/CMakeLists.txt +++ b/deps/ox/src/ox/CMakeLists.txt @@ -1,3 +1,6 @@ +if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + set(OX_OS_WINDOWS TRUE) +endif() if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") set(OX_OS_FREEBSD TRUE) else() diff --git a/deps/ox/src/ox/logconn/CMakeLists.txt b/deps/ox/src/ox/logconn/CMakeLists.txt index e505fdb6..ad218cdc 100644 --- a/deps/ox/src/ox/logconn/CMakeLists.txt +++ b/deps/ox/src/ox/logconn/CMakeLists.txt @@ -21,6 +21,7 @@ target_link_libraries( OxStd OxMetalClaw $<$:pthread> + $<$:ws2_32> ) install( diff --git a/deps/ox/src/ox/logconn/logconn.cpp b/deps/ox/src/ox/logconn/logconn.cpp index 4cfc4b63..7c64ea6f 100644 --- a/deps/ox/src/ox/logconn/logconn.cpp +++ b/deps/ox/src/ox/logconn/logconn.cpp @@ -9,22 +9,36 @@ #ifdef OX_USE_STDLIB #include +#include #ifndef _WIN32 #include #include #include #include +#else +#include +#undef interface +#undef min +#undef max #endif -#include -#include #include "logconn.hpp" +#include + namespace ox { using namespace trace; +void closeSock(auto s) noexcept { +#ifdef _WIN32 + closesocket(s); +#else + close(s); +#endif +} + LoggerConn::LoggerConn() noexcept: m_netThread([this]{this->msgSend();}) { } @@ -33,7 +47,7 @@ LoggerConn::~LoggerConn() noexcept { m_waitCond.notify_one(); m_netThread.join(); if (m_socket) { - close(m_socket); + closeSock(m_socket); } } diff --git a/deps/ox/src/ox/logconn/logconn.hpp b/deps/ox/src/ox/logconn/logconn.hpp index a7273017..152005cc 100644 --- a/deps/ox/src/ox/logconn/logconn.hpp +++ b/deps/ox/src/ox/logconn/logconn.hpp @@ -17,7 +17,7 @@ #include #include -#include "circularbuff.hpp" +#include "circularbuff.hpp" namespace ox {