diff -r a76af67a3a4b -r 7b156b764d11 sources/basics.h --- a/sources/basics.h Sat Jan 09 02:35:00 2016 +0200 +++ b/sources/basics.h Sat Jan 09 17:41:21 2016 +0200 @@ -29,40 +29,24 @@ */ #pragma once -#include -#include +#if !defined(_MSC_VER) && !defined(__cdecl) +# define __cdecl +#endif -#define FUNCTION auto -#define STATIC -#define METHOD auto #define MACRO_TO_STRING_2(A) #A #define MACRO_TO_STRING(A) MACRO_TO_STRING_2(A) -class String; - -using std::swap; -using std::min; -using std::max; - -template -using Function = std::function; +// The Windows SDK appears to use identifiers that conflicts with the identifiers defined in ZFC, +// so they have to be put in a namespace. +#define BEGIN_ZFC_NAMESPACE namespace zfc { +#define END_ZFC_NAMESPACE } -// ------------------------------------------------------------------------------------------------- -// -enum Color -{ - BLACK, - RED, - GREEN, - YELLOW, - BLUE, - MAGENTA, - CYAN, - WHITE, - DEFAULT, - - NUM_COLORS -}; +// Goddamnit, MSVC +#ifdef _MSC_VER +# define and && +# define or || +# define not ! +#endif #define TEXTCOLOR_Escape "\x1C" #define TEXTCOLOR_Black TEXTCOLOR_Escape "M" @@ -81,18 +65,29 @@ #define TEXTCOLOR_BrightCyan TEXTCOLOR_Escape "V" #define TEXTCOLOR_Reset TEXTCOLOR_Escape "-" -// ------------------------------------------------------------------------------------------------- -// -FUNCTION print_to_console (String a) -> void; +#undef min +#undef max + +BEGIN_ZFC_NAMESPACE -// ------------------------------------------------------------------------------------------------- -// -template inline FUNCTION -clamp (T a, T b, T c) -> T +template +T min (T a, T b) +{ + return (a < b) ? a : b; +} + +template +T max (T a, T b) +{ + return (a > b) ? a : b; +} + +template +T clamp (T a, T b, T c) { return (a < b) ? b : (a > c) ? c : a; } -// ------------------------------------------------------------------------------------------------- -// struct Exitception {}; + +END_ZFC_NAMESPACE