1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-06 10:17:13 +02:00

Automatic OS identification.

This commit is contained in:
Sandu Liviu Catalin 2020-04-27 10:37:39 +03:00
parent a6ce7811ba
commit b0e7c305b6
4 changed files with 19 additions and 4 deletions

View File

@ -12,9 +12,6 @@ target_include_directories(SimpleSocket PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include
# Configure macro options # Configure macro options
target_compile_definitions(SimpleSocket PRIVATE _WIN32_WINNT=0x0601) target_compile_definitions(SimpleSocket PRIVATE _WIN32_WINNT=0x0601)
# OS and compiler checks. # OS and compiler checks.
if(UNIX) if(WIN32)
target_compile_definitions(SimpleSocket PRIVATE _LINUX=1)
elseif(WIN32)
target_compile_definitions(SimpleSocket PRIVATE _WIN32=1)
target_link_libraries(SimpleSocket PUBLIC Ws2_32) target_link_libraries(SimpleSocket PUBLIC Ws2_32)
endif() endif()

View File

@ -54,6 +54,19 @@ extern "C"
{ {
#endif #endif
/*---------------------------------------------------------------------------*/
/* */
/* OS Identification */
/* */
/*---------------------------------------------------------------------------*/
#if defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__WIN64__) || defined(_WIN) || defined(__WIN__)
#ifndef _WIN32
#define _WIN32 // why do I even bother?
#endif
#elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__unix) || defined(__unix__)
#define _LINUX
#endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* */ /* */
/* Type Definition Macros */ /* Type Definition Macros */

View File

@ -43,6 +43,10 @@
#ifndef __SOCKET_H__ #ifndef __SOCKET_H__
#define __SOCKET_H__ #define __SOCKET_H__
#ifdef _LINUX
#define _DEFAULT_SOURCE
#endif
#include <sys/stat.h> #include <sys/stat.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>

View File

@ -51,6 +51,7 @@
#endif #endif
#ifdef _LINUX #ifdef _LINUX
#define _DEFAULT_SOURCE
#include <stdio.h> #include <stdio.h>
#include <sys/time.h> #include <sys/time.h>
#endif #endif