platform
This commit is contained in:
@@ -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
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#include "./types.hpp"
|
||||||
|
|
||||||
typedef s32 testresult;
|
typedef s32 testresult;
|
||||||
|
|
||||||
#define epsilon 2.2204460492503131E-16
|
#define epsilon 2.2204460492503131E-16
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "platform.hpp"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -27,10 +28,18 @@ struct String {
|
|||||||
char* data;
|
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 {
|
inline auto make_heap_string(const char* str) -> String {
|
||||||
String ret;
|
String ret;
|
||||||
ret.length = strlen(str);
|
ret.length = strlen(str);
|
||||||
ret.data = _strdup(str);
|
ret.data = heap_copy_c_string(str);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user