diff options
Diffstat (limited to 'include/libHX/defs.h')
-rw-r--r-- | include/libHX/defs.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/include/libHX/defs.h b/include/libHX/defs.h index 1ace518..9d17019 100644 --- a/include/libHX/defs.h +++ b/include/libHX/defs.h @@ -10,8 +10,8 @@ # endif # ifndef containerof # include <cstddef> -# define containerof(var, type, member) reinterpret_cast<type *>( \ - reinterpret_cast<char *>(var) - offsetof(type, member)) +# include <type_traits> +# define containerof(var, T, member) reinterpret_cast<std::conditional<std::is_const<std::remove_pointer<decltype(var)>::type>::value, std::add_const<T>::type, T>::type *>(reinterpret_cast<std::conditional<std::is_const<std::remove_pointer<decltype(var)>::type>::value, const char, char>::type *>(var) - offsetof(T, member)) # endif # ifndef static_cast # define static_cast(T, x) static_cast<T>(x) @@ -213,15 +213,15 @@ static __inline__ new_type signed_cast(unsigned char *expr) # define container_of(v, s, m) containerof((v), s, m) #endif -#ifdef _WIN32 +#if !defined(_WIN32) || (defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO + 0 > 0) /* * Sufficiently old versions of the VC runtime do not even support %ll. */ -# define HX_LONGLONG_FMT "I64" -# define HX_SIZET_FMT "I" -#else # define HX_LONGLONG_FMT "ll" # define HX_SIZET_FMT "z" +#else +# define HX_LONGLONG_FMT "I64" +# define HX_SIZET_FMT "I" #endif #endif /* _LIBHX_DEFS_H */ |