The normal assert.h is very rude in that it clobbers any existing assert
define and replaces it with its own. An sadly, lots of things we include
include the generic version.
Be extra rude in response. Clobber any existing assert #define, and also
#define _ASSERT_H to be a magic value that our commonly-used dendl #define
depends on. This way we get a compile error if the system version replaces
out own.
This is imperfect, since we will only detect their rudeness when we use
the debug macros. I'm not coming up with something that is more widely
used that would work better, however.
Signed-off-by: Sage Weil <sage@inktank.com>
#define lgeneric_dout(cct, v) dout_impl(cct, ceph_subsys_, v) *_dout
#define lgeneric_derr(cct) dout_impl(cct, ceph_subsys_, -1) *_dout
+// NOTE: depend on magic value in _ASSERT_H so that we detect when
+// /usr/include/assert.h clobbers our fancier version.
#define dendl std::flush; \
- _dout_cct->_log->submit_entry(_dout_e); \
+ _ASSERT_H->_log->submit_entry(_dout_e); \
} \
} while (0)
# undef assert
#endif
+// make _ASSERT_H something that *must* have a value other than what
+// /usr/include/assert.h gives it (nothing!), so that we detect when
+// our assert is clobbered.
+#undef _ASSERT_H
+#define _ASSERT_H _dout_cct
+
#define assert(expr) \
((expr) \
? __CEPH_ASSERT_VOID_CAST (0) \
: __ceph_assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION))
-#undef _ASSERT_H