diff options
author | dmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-10 21:36:06 +0000 |
---|---|---|
committer | dmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-10 21:36:06 +0000 |
commit | 7631cf8806adf505db4fed53210e27d2d1dd2cd0 (patch) | |
tree | 334a70835e67cbfdf4257b0e9041950b3082d009 /ppapi/c/pp_var.h | |
parent | 3ce42e2d90efdb63b2f34d62b48e7ae3901566fb (diff) | |
download | chromium_src-7631cf8806adf505db4fed53210e27d2d1dd2cd0.zip chromium_src-7631cf8806adf505db4fed53210e27d2d1dd2cd0.tar.gz chromium_src-7631cf8806adf505db4fed53210e27d2d1dd2cd0.tar.bz2 |
Add a macro (PP_ENUM) that ensures that enums are always 4 bytes. Wherever
possible (Visual Studio C++ and GCC C++0x mode), specify int32_t as the representation type of the enum. For C, where enum gives us no type safety, just typedef an int32_t to the enum name. In all other cases, use a compile-time assertion to ensure that enums are 4 bytes wide.
This change only applies the new PP_ENUM macro in 2 commonly used places. This is to make sure that the (possibly contraversial) usage of variadic macro arguments is acceptable before I go change it everywhere. If I can't use variadic macro arguments, I think I will have to separate this in to 2 macros and the enum declarations will look something like this:
PP_ENUM_BEGIN(PP_Bool)
PP_FALSE=0, PP_TRUE=1
PP_ENUM_END(PP_Bool)
BUG=61004
TEST=This should be exercised by all tests that use PP_Bool and PP_Var.
Suggestions for improvement are welcome, as always.
Review URL: http://codereview.chromium.org/4720005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65704 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/c/pp_var.h')
-rw-r--r-- | ppapi/c/pp_var.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/ppapi/c/pp_var.h b/ppapi/c/pp_var.h index 81596d6..fad5db4 100644 --- a/ppapi/c/pp_var.h +++ b/ppapi/c/pp_var.h @@ -27,6 +27,8 @@ typedef enum { PP_VARTYPE_OBJECT } PP_VarType; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VarType, 4); + /** * Do not rely on having a predictable and reproducible * int/double differentiation. |