mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
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.
This commit is contained in:
@@ -8,13 +8,23 @@
|
||||
#include "tcpsockets/SocketError.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <WinSock2.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
namespace wpi {
|
||||
|
||||
int SocketErrno() {
|
||||
#ifdef _WIN32
|
||||
return WSAGetLastError();
|
||||
#else
|
||||
return errno;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string SocketStrerror(int code) {
|
||||
#ifdef _WIN32
|
||||
LPSTR errstr = nullptr;
|
||||
|
||||
@@ -10,21 +10,9 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <WinSock2.h>
|
||||
#else
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
namespace wpi {
|
||||
|
||||
static inline int SocketErrno() {
|
||||
#ifdef _WIN32
|
||||
return WSAGetLastError();
|
||||
#else
|
||||
return errno;
|
||||
#endif
|
||||
}
|
||||
int SocketErrno();
|
||||
|
||||
std::string SocketStrerror(int code);
|
||||
|
||||
|
||||
@@ -27,12 +27,6 @@
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#include "tcpsockets/NetworkStream.h"
|
||||
|
||||
struct sockaddr_in;
|
||||
|
||||
Reference in New Issue
Block a user