From e089810f24a6a8b953e2a4e2fa42f09a86a9b8d6 Mon Sep 17 00:00:00 2001 From: "wtc%google.com" Date: Mon, 28 May 2007 14:48:26 +0000 Subject: [PATCH] Bugzilla bug 375985: Moved the definition of PR_STATIC_ASSERT from perror.h to prlog.h, where the related PR_ASSERT macro is defined. Define PR_STATIC_ASSERT as an extern declaration rather than a typedef. The patch is adapted from Igor Bukanov's patch in JavaScript bug 381236 JS_STATIC_ASSERT. r=igor@mir2.org. Modified files: prerror.h prlog.h git-svn-id: svn://10.0.0.236/trunk@227110 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/nsprpub/pr/include/prerror.h | 15 --------------- mozilla/nsprpub/pr/include/prlog.h | 8 ++++++++ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/mozilla/nsprpub/pr/include/prerror.h b/mozilla/nsprpub/pr/include/prerror.h index af2cb9164ab..cf94872e306 100644 --- a/mozilla/nsprpub/pr/include/prerror.h +++ b/mozilla/nsprpub/pr/include/prerror.h @@ -48,21 +48,6 @@ 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 diff --git a/mozilla/nsprpub/pr/include/prlog.h b/mozilla/nsprpub/pr/include/prlog.h index 6b88a5cbfa7..2a65b3de933 100644 --- a/mozilla/nsprpub/pr/include/prlog.h +++ b/mozilla/nsprpub/pr/include/prlog.h @@ -251,6 +251,14 @@ NSPR_API(void) PR_Assert(const char *s, const char *file, PRIntn ln); #endif /* defined(DEBUG) || defined(FORCE_PR_ASSERT) */ +/* +** Compile-time assert. "condition" must be a constant expression. +** The macro can be used only in places where an "extern" declaration is +** allowed. +*/ +#define PR_STATIC_ASSERT(condition) \ + extern void pr_static_assert(int arg[(condition) ? 1 : -1]) + PR_END_EXTERN_C #endif /* prlog_h___ */