diff options
author | Sage Weil <sage@inktank.com> | 2012-06-06 16:06:28 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-06-06 16:07:04 -0700 |
commit | a30601a1b69c3f1ac5cfa592050877aec8b5be9d (patch) | |
tree | dfa1f69e89a4447ce08ec14c4a7a585f461f21a7 /src/include/assert.h | |
parent | 2be716cfcb68cb9390261261debd296a1c158a13 (diff) | |
download | ceph-a30601a1b69c3f1ac5cfa592050877aec8b5be9d.tar.gz |
assert: detect when /usr/include/assert.h clobbers us
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>
Diffstat (limited to 'src/include/assert.h')
-rw-r--r-- | src/include/assert.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/include/assert.h b/src/include/assert.h index 08a13daa2d4..81a37a84be6 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -105,9 +105,14 @@ using namespace ceph; # 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 |