/*
* _bt_is_signed_type() willingly generates comparison of unsigned
* expression < 0, which is always false. Silence compiler warnings.
+ * GCC versions lower than 4.6.0 do not accept diagnostic pragma inside
+ * functions.
*/
-#ifdef __GNUC__
+#if defined(__GNUC__) && (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600
# define _BT_DIAG_PUSH _Pragma("GCC diagnostic push")
# define _BT_DIAG_POP _Pragma("GCC diagnostic pop")
# define _BT_DIAG_PUSH
# define _BT_DIAG_POP
# define _BT_DIAG_IGNORE
+# define _BT_DIAG_IGNORE_TYPE_LIMITS
#endif
#define _bt_is_signed_type(type) ((type) -1 < (type) 0)
* Produce a build-time error if the condition `cond` is non-zero.
* Evaluates as a size_t expression.
*/
+#ifdef __cplusplus
+#define _BT_BUILD_ASSERT(cond) ([]{static_assert((cond), "");}, 0)
+#else
#define _BT_BUILD_ASSERT(cond) \
sizeof(struct { int f:(2 * !!(cond) - 1); })
+#endif
/*
* Cast value `v` to an unsigned integer of the same size as `v`.
do { \
__typeof__(*(vptr)) *_vptr = (vptr); \
__typeof__(*_vptr) _v; \
- type *_ptr = (void *) (ptr); \
+ type *_ptr = (type *) (ptr); \
unsigned long _start = (start), _length = (length); \
type _mask, _cmask; \
unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \