From 73654c2079a234e6e595506faf5c2671d3e96322 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Wed, 12 Apr 2017 08:30:32 +0000 Subject: [PATCH] compat.h: Add new types, native_t and unative_t, functionally equivalent to our current bssize_t and bsize_t, respectively, but generated dependably using template metaprogramming when building with C++ >= 11. git-svn-id: https://svn.eduke32.com/eduke32@6118 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/compat.h | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/source/build/include/compat.h b/source/build/include/compat.h index 2d37bb5f3..df30be324 100644 --- a/source/build/include/compat.h +++ b/source/build/include/compat.h @@ -650,6 +650,33 @@ template using conditional_t = typename std::conditional::type; # endif +template +struct integers_of_size { }; +template <> +struct integers_of_size +{ + typedef int8_t i; + typedef uint8_t u; +}; +template <> +struct integers_of_size +{ + typedef int16_t i; + typedef uint16_t u; +}; +template <> +struct integers_of_size +{ + typedef int32_t i; + typedef uint32_t u; +}; +template <> +struct integers_of_size +{ + typedef int64_t i; + typedef uint64_t u; +}; + #endif @@ -666,6 +693,15 @@ private: }; #endif +#if CXXSTD >= 2011 +using native_t = typename integers_of_size::i; +using unative_t = typename integers_of_size::u; +#else +typedef ssize_t native_t; +typedef size_t unative_t; +#endif +EDUKE32_STATIC_ASSERT(sizeof(native_t) == sizeof(unative_t)); + typedef struct { int32_t x, y; } vec2_t;