From eb1d178de322c3938ca2e34452dd109b330d96cc Mon Sep 17 00:00:00 2001 From: Felix Brendel Date: Tue, 29 Sep 2020 17:31:35 +0200 Subject: [PATCH] platform --- platform.hpp | 9 +++++++++ testing.hpp | 2 ++ types.hpp | 11 ++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 platform.hpp diff --git a/platform.hpp b/platform.hpp new file mode 100644 index 0000000..3dbfa6d --- /dev/null +++ b/platform.hpp @@ -0,0 +1,9 @@ +#pragma once + +#if defined(_WIN32) || defined(_WIN64) +#pragma message("Compiling for Windows") +#define FTB_WINDOWS +#elseif +#pragma message("Compiling for Linux") +#define FTB_LINUX +#endif diff --git a/testing.hpp b/testing.hpp index 312d4dd..36a75a6 100644 --- a/testing.hpp +++ b/testing.hpp @@ -1,3 +1,5 @@ +#include "./types.hpp" + typedef s32 testresult; #define epsilon 2.2204460492503131E-16 diff --git a/types.hpp b/types.hpp index 760285b..0e1784b 100644 --- a/types.hpp +++ b/types.hpp @@ -1,5 +1,6 @@ #pragma once +#include "platform.hpp" #include #include @@ -27,10 +28,18 @@ struct String { char* data; }; +inline auto heap_copy_c_string(const char* str) -> char* { +#ifdef FTB_WINDOWS + return _strdup(str); +#else + return strdup(str); +#endif +} + inline auto make_heap_string(const char* str) -> String { String ret; ret.length = strlen(str); - ret.data = _strdup(str); + ret.data = heap_copy_c_string(str); return ret; }