Bugzilla bug 375985: Moved the definition of PR_STATIC_ASSERT from perror.h NSPRPUB_PRE_4_2_CLIENT_BRANCH MOZILLA_1_9a5_RC1 MOZILLA_1_9a5_RC2 MOZILLA_1_9a5_RELEASE MOZILLA_1_9a6_RC1 MOZILLA_1_9a6_RC2 MOZILLA_1_9a6_RELEASE ROMAXA_20070529_GTK2_THEBES_BASE WEB_CONTENT_HANDLING_20070621_BASE WEB_CONTENT_HANDLING_20070621_POSTMERGE_20070607 WEB_CONTENT_HANDLING_20070621_PREMERGE_20070607 WEB_CONTENT_HANDLING_20070621_PRE_LAUNCHWITHURI
authorwtc%google.com
Mon, 28 May 2007 14:49:42 +0000
branchNSPRPUB_PRE_4_2_CLIENT_BRANCH
changeset 3844 e290783d4531e078dcd63c1eefc223d03568aad8
parent 3842 2002506978437762f8b9ba9966065440be6baa7c
child 3845 ea128705cb33f23ce8fb554d3c9f856762f7527d
child 3846 46900a58710509e92d9ef7f402ae2f470fd8608e
child 3850 4c8109e865dc0db85e4714c55ec7d6bfde442d7d
push idunknown
push userunknown
push dateunknown
bugs375985, 381236
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 Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
pr/include/prerror.h
pr/include/prlog.h
--- a/pr/include/prerror.h
+++ b/pr/include/prerror.h
@@ -44,31 +44,16 @@ PR_BEGIN_EXTERN_C
 
 typedef PRInt32 PRErrorCode;
 
 #define PR_NSPR_ERROR_BASE -6000
 
 #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.
 ** If there is no appropriate OS error number, a zero my be supplied.
 */
 NSPR_API(void) PR_SetError(PRErrorCode errorCode, PRInt32 oserr);
 
 /*
--- a/pr/include/prlog.h
+++ b/pr/include/prlog.h
@@ -246,11 +246,19 @@ NSPR_API(void) PR_Assert(const char *s, 
 
 #else
 
 #define PR_ASSERT(expr) ((void) 0)
 #define PR_NOT_REACHED(reasonStr)
 
 #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___ */