mirror of
https://github.com/SantaSpeen/BeamMP-Server.git
synced 2026-02-16 08:20:40 +00:00
Add BEAMMP_{WINDOWS,LINUX,APPLE} preprocessor defines instead of platform specific ones
This commit is contained in:
@@ -13,10 +13,10 @@
|
||||
|
||||
class TServer;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef BEAMMP_WINDOWS
|
||||
// for socklen_t
|
||||
#include <WS2tcpip.h>
|
||||
#endif // WIN32
|
||||
#endif // WINDOWS
|
||||
|
||||
struct TConnection final {
|
||||
SOCKET Socket;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Environment.h"
|
||||
|
||||
// ======================= UNIX ========================
|
||||
|
||||
#ifdef __unix
|
||||
#ifdef BEAMMP_LINUX
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <termios.h>
|
||||
@@ -19,7 +21,9 @@ inline void CloseSocketProper(int TheSocket) {
|
||||
}
|
||||
#endif // unix
|
||||
|
||||
#ifdef __APPLE__
|
||||
// ======================= APPLE ========================
|
||||
|
||||
#ifdef BEAMMP_APPLE
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <termios.h>
|
||||
@@ -36,9 +40,9 @@ inline void CloseSocketProper(int TheSocket) {
|
||||
}
|
||||
#endif // unix
|
||||
|
||||
// ======================= WIN32 =======================
|
||||
// ======================= WINDOWS =======================
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef BEAMMP_WINDOWS
|
||||
#include <conio.h>
|
||||
#include <winsock2.h>
|
||||
inline void CloseSocketProper(SOCKET TheSocket) {
|
||||
@@ -47,9 +51,3 @@ inline void CloseSocketProper(SOCKET TheSocket) {
|
||||
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
// ======================= OTHER =======================
|
||||
|
||||
#if !defined(WIN32) && !defined(__unix) && !defined(__APPLE__)
|
||||
#error "OS not supported"
|
||||
#endif
|
||||
17
include/Environment.h
Normal file
17
include/Environment.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
// one of BEAMMP_{WINDOWS,LINUX,APPLE} will be set at the end of this
|
||||
|
||||
// clang-format off
|
||||
#if !defined(BEAMMP_WINDOWS) && !defined(BEAMMP_UNIX) && !defined(BEAMMP_APPLE)
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#define BEAMMP_WINDOWS
|
||||
#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__unix__) || defined(__unix) || defined(unix)
|
||||
#define BEAMMP_LINUX
|
||||
#elif defined(__APPLE__) || defined(__MACH__)
|
||||
#define BEAMMP_APPLE
|
||||
#else
|
||||
#error "This platform is not known. Please define one of the above for your OS."
|
||||
#endif
|
||||
#endif
|
||||
// clang-format on
|
||||
Reference in New Issue
Block a user