|
FreeRDP
|
24 #include <winpr/assert-api.h>
31 #define WINPR_CXX_COMPAT_CAST(t, val) static_cast<t>(val)
33 #define WINPR_CXX_COMPAT_CAST(t, val) (t)(val)
36 #if defined(__GNUC__) || defined(__clang__)
44 #define WINPR_REINTERPRET_CAST(ptr, srcType, dstType) \
51 WINPR_STATIC_ASSERT(sizeof(srcType) == sizeof(dstType)); \
63 #define WINPR_CAST_CONST_PTR_AWAY(ptr, dstType) \
81 #define WINPR_FUNC_PTR_CAST(ptr, dstType) \
88 WINPR_STATIC_ASSERT(sizeof(dstType) == sizeof(__typeof(ptr))); \
94 #define WINPR_REINTERPRET_CAST(ptr, srcType, dstType) (dstType) ptr
95 #define WINPR_CAST_CONST_PTR_AWAY(ptr, dstType) (dstType) ptr
96 #define WINPR_FUNC_PTR_CAST(ptr, dstType) (dstType)(uintptr_t) ptr
99 #if defined(__GNUC__) || defined(__clang__)
111 #define WINPR_ASSERTING_INT_CAST(type, var) \
113 WINPR_ASSERT((var) == \
114 WINPR_CXX_COMPAT_CAST(__typeof(var), WINPR_CXX_COMPAT_CAST(type, (var)))); \
115 WINPR_ASSERT((((var) > 0) && (WINPR_CXX_COMPAT_CAST(type, (var)) > 0)) || \
116 (((var) <= 0) && WINPR_CXX_COMPAT_CAST(type, (var)) <= 0)); \
117 WINPR_CXX_COMPAT_CAST(type, (var)); \
121 #define WINPR_ASSERTING_INT_CAST(type, var) WINPR_CXX_COMPAT_CAST(type, var)