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

Unified Diff: ppapi/c/pp_macros.h

Issue 5674004: Add compile assertions to enforce the sizes of all structs and enums in the C... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years 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
Index: ppapi/c/pp_macros.h
===================================================================
--- ppapi/c/pp_macros.h (revision 68603)
+++ ppapi/c/pp_macros.h (working copy)
@@ -53,7 +53,7 @@
SIZE is the expected size in bytes.
*/
#define PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, CTYPENAME, SIZE) \
-struct _dummy_struct_for_##NAME { \
+struct PP_Dummy_Struct_For_##NAME { \
char _COMPILE_ASSERT_FAILED_The_type_named_ \
## NAME ## _is_not_ ## SIZE ## \
_bytes_wide[(sizeof(CTYPENAME) == SIZE) ? 1 : -1]; }
@@ -76,6 +76,15 @@
#define PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(NAME, SIZE) \
PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, struct NAME, SIZE)
+/* PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES is for typenames that contain 'enum'
+ in C. That is, enum names that are not typedefs.
+ E.g.:
+ enum Bar { A = 0, B = 1 };
+ PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(Foo, 4);
+ */
+#define PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(NAME, SIZE) \
+PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, enum NAME, SIZE)
+
/**
* @}
* End of addtogroup PP
« ppapi/c/dev/pp_video_dev.h ('K') | « ppapi/c/pp_instance.h ('k') | ppapi/c/pp_module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698