From 68501759fabd9cb95080be458fd03651846959df Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 23 Aug 2017 01:27:19 -0500 Subject: [PATCH] tcpsockets: Don't pull in platform-specific headers in headers. (#26) This pollutes the namespace for all users of these headers. This is particularly an issue on Windows. --- src/main/native/cpp/tcpsockets/SocketError.cpp | 10 ++++++++++ src/main/native/include/tcpsockets/SocketError.h | 14 +------------- src/main/native/include/tcpsockets/TCPStream.h | 6 ------ 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/main/native/cpp/tcpsockets/SocketError.cpp b/src/main/native/cpp/tcpsockets/SocketError.cpp index a2628fdd2b..2db2a24c54 100644 --- a/src/main/native/cpp/tcpsockets/SocketError.cpp +++ b/src/main/native/cpp/tcpsockets/SocketError.cpp @@ -8,13 +8,23 @@ #include "tcpsockets/SocketError.h" #ifdef _WIN32 +#include #include #else +#include #include #endif namespace wpi { +int SocketErrno() { +#ifdef _WIN32 + return WSAGetLastError(); +#else + return errno; +#endif +} + std::string SocketStrerror(int code) { #ifdef _WIN32 LPSTR errstr = nullptr; diff --git a/src/main/native/include/tcpsockets/SocketError.h b/src/main/native/include/tcpsockets/SocketError.h index 3d87b2d5c9..0835797270 100644 --- a/src/main/native/include/tcpsockets/SocketError.h +++ b/src/main/native/include/tcpsockets/SocketError.h @@ -10,21 +10,9 @@ #include -#ifdef _WIN32 -#include -#else -#include -#endif - namespace wpi { -static inline int SocketErrno() { -#ifdef _WIN32 - return WSAGetLastError(); -#else - return errno; -#endif -} +int SocketErrno(); std::string SocketStrerror(int code); diff --git a/src/main/native/include/tcpsockets/TCPStream.h b/src/main/native/include/tcpsockets/TCPStream.h index 89e3779778..d58e6a979d 100644 --- a/src/main/native/include/tcpsockets/TCPStream.h +++ b/src/main/native/include/tcpsockets/TCPStream.h @@ -27,12 +27,6 @@ #include #include -#ifdef _WIN32 -#include -#else -#include -#endif - #include "tcpsockets/NetworkStream.h" struct sockaddr_in;