Bug 381236: static assert that does not depend on __LINE__

This commit is contained in:
igor%mir2.org 2007-05-24 07:27:45 +00:00
Родитель a462976bf8
Коммит a2d68820d0
1 изменённых файлов: 3 добавлений и 7 удалений

Просмотреть файл

@ -69,15 +69,11 @@ JS_Assert(const char *s, const char *file, JSIntn ln);
/* /*
* Compile-time assert. "condition" must be a constant expression. * Compile-time assert. "condition" must be a constant expression.
* The macro should be used only once per source line in places where * The macro can be used only in places where an "extern" declaration is
* a "typedef" declaration is allowed. * allowed.
*/ */
#define JS_STATIC_ASSERT(condition) \ #define JS_STATIC_ASSERT(condition) \
JS_STATIC_ASSERT_IMPL(condition, __LINE__) extern void js_static_assert(int arg[(condition) ? 1 : -1])
#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]
/* /*
** Abort the process in a non-graceful manner. This will cause a core file, ** Abort the process in a non-graceful manner. This will cause a core file,