зеркало из https://github.com/mozilla/pjs.git
Bug 381236: static assert that does not depend on __LINE__
This commit is contained in:
Родитель
a462976bf8
Коммит
a2d68820d0
|
@ -69,15 +69,11 @@ JS_Assert(const char *s, const char *file, JSIntn ln);
|
|||
|
||||
/*
|
||||
* 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.
|
||||
* The macro can be used only in places where an "extern" declaration is
|
||||
* allowed.
|
||||
*/
|
||||
#define JS_STATIC_ASSERT(condition) \
|
||||
JS_STATIC_ASSERT_IMPL(condition, __LINE__)
|
||||
#define JS_STATIC_ASSERT_IMPL(condition, line) \
|
||||
JS_STATIC_ASSERT_IMPL2(condition, line)
|
||||
#define JS_STATIC_ASSERT_IMPL2(condition, line) \
|
||||
typedef int js_static_assert_line_##line[(condition) ? 1 : -1]
|
||||
extern void js_static_assert(int arg[(condition) ? 1 : -1])
|
||||
|
||||
/*
|
||||
** Abort the process in a non-graceful manner. This will cause a core file,
|
||||
|
|
Загрузка…
Ссылка в новой задаче