diff options
author | jwatt%jwatt.org <devnull@localhost> | 2007-04-02 09:05:50 +0000 |
---|---|---|
committer | jwatt%jwatt.org <devnull@localhost> | 2007-04-02 09:05:50 +0000 |
commit | 55caee49e19b843a679bf0380bcd04ddd417426f (patch) | |
tree | f6e29fa5aa50f238e922c15c5782f611aef37d88 | |
parent | 806ee4140c48ae151467977ffd121c2b1aeed335 (diff) | |
download | nspr-hg-55caee49e19b843a679bf0380bcd04ddd417426f.tar.gz |
Fixing bug 375985. Add compile time assertions to NSPR. r=wtchang@gmail.com
-rw-r--r-- | pr/include/prerror.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pr/include/prerror.h b/pr/include/prerror.h index cf94872e..af2cb916 100644 --- a/pr/include/prerror.h +++ b/pr/include/prerror.h @@ -49,6 +49,21 @@ typedef PRInt32 PRErrorCode; #include "prerr.h" /* +** Compile-time assert. "condition" must be a constant expression. +** The macro should be used only once per source line in places where +** a "typedef" declaration is allowed. +** For stringification of the line numbers where the macro is used we need some +** macro indirection. IMPL is required to get macro-expansion of __LINE__ to +** its integer value so that IMPL2 will stringify the number, not "__LINE__". +*/ +#define PR_STATIC_ASSERT(condition) \ + PR_STATIC_ASSERT_IMPL(condition, __LINE__) +#define PR_STATIC_ASSERT_IMPL(condition, line) \ + PR_STATIC_ASSERT_IMPL2(condition, line) +#define PR_STATIC_ASSERT_IMPL2(condition, line) \ + typedef int pr_static_assert_line_##line[(condition) ? 1 : -1] + +/* ** Set error will preserve an error condition within a thread context. ** The values stored are the NSPR (platform independent) translation of ** the error. Also, if available, the platform specific oserror is stored. |