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
This commit is contained in:
parent
9e8d8775fc
commit
e089810f24
@ -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
|
||||
|
||||
@ -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___ */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user