diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-02-10 15:27:06 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-02-10 15:27:06 +0100 |
commit | 7501bff8432444b7ae8e7f3d9289c0d61f3f0b64 (patch) | |
tree | bd53603f464c3747e897a8996158a0fef7b41bc3 /include/libHX/defs.h | |
parent | 0f124df68d87c9073f76efeff1a901a69b1f3e13 (diff) | |
parent | 9e9336185f86bd97ff22f54e4d561c2cccccecf5 (diff) |
Merge branch 'release/debian/4.10-1'debian/4.10-1
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 */ |