1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-01-31 09:57:14 +01: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
target_compile_definitions(SimpleSocket PRIVATE _WIN32_WINNT=0x0601)
# OS and compiler checks.
if(UNIX)
target_compile_definitions(SimpleSocket PRIVATE _LINUX=1)
elseif(WIN32)
target_compile_definitions(SimpleSocket PRIVATE _WIN32=1)
if(WIN32)
target_link_libraries(SimpleSocket PUBLIC Ws2_32)
endif()

View File

@ -54,6 +54,19 @@ extern "C"
{
#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 */

View File

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

View File

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