Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: runtime/platform/assert.h

Issue 298963006: Change COMPILE_ASSERT to take only one argument and use it in more places. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/assembler_arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/assert.h
===================================================================
--- runtime/platform/assert.h (revision 36621)
+++ runtime/platform/assert.h (working copy)
@@ -274,26 +274,25 @@
// expression is true. For example, you could use it to verify the
// size of a static array:
//
-// COMPILE_ASSERT(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES,
-// content_type_names_incorrect_size);
+// COMPILE_ASSERT(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES);
//
// or to make sure a struct is smaller than a certain size:
//
-// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large);
+// COMPILE_ASSERT(sizeof(foo) < 128);
//
-// The second argument to the macro is the name of the variable. If
-// the expression is false, most compilers will issue a warning/error
-// containing the name of the variable.
template <bool>
struct CompileAssert {
};
-
-#define COMPILE_ASSERT(expr, msg) \
+// Macro to concatenate two tokens. The helper is need to proper expansion
+// in case an argument is a macro itself.
+#define COMPILE_ASSERT_JOIN(a, b) COMPILE_ASSERT_JOIN_HELPER(a, b)
+#define COMPILE_ASSERT_JOIN_HELPER(a, b) a##b
+#define COMPILE_ASSERT(expr) \
DART_UNUSED typedef CompileAssert<(static_cast<bool>(expr))> \
- msg[static_cast<bool>(expr) ? 1 : -1]
+ COMPILE_ASSERT_JOIN(CompileAssertTypeDef, __LINE__)[static_cast<bool>(expr) \
+ ? 1 : -1]
-
#if defined(TESTING)
// EXPECT and FAIL are equivalent to ASSERT and FATAL except that they do not
« no previous file with comments | « no previous file | runtime/vm/assembler_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698