OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PPAPI_C_PP_MACROS_H_ | 5 #ifndef PPAPI_C_PP_MACROS_H_ |
6 #define PPAPI_C_PP_MACROS_H_ | 6 #define PPAPI_C_PP_MACROS_H_ |
7 | 7 |
8 /** | 8 /** |
9 * @file | 9 * @file |
10 * Defines the API ... | 10 * Defines the API ... |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 | 46 |
47 NAME is the name of the type without any spaces or the struct or enum | 47 NAME is the name of the type without any spaces or the struct or enum |
48 keywords. | 48 keywords. |
49 | 49 |
50 CTYPENAME is the typename required by C. I.e., for a struct or enum, the | 50 CTYPENAME is the typename required by C. I.e., for a struct or enum, the |
51 appropriate keyword must be included. | 51 appropriate keyword must be included. |
52 | 52 |
53 SIZE is the expected size in bytes. | 53 SIZE is the expected size in bytes. |
54 */ | 54 */ |
55 #define PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, CTYPENAME, SIZE) \ | 55 #define PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, CTYPENAME, SIZE) \ |
56 struct _dummy_struct_for_##NAME { \ | 56 struct Dummy_Struct_For_##NAME { \ |
57 char _COMPILE_ASSERT_FAILED_The_type_named_ \ | 57 char _COMPILE_ASSERT_FAILED_The_type_named_ \ |
58 ## NAME ## _is_not_ ## SIZE ## \ | 58 ## NAME ## _is_not_ ## SIZE ## \ |
59 _bytes_wide[(sizeof(CTYPENAME) == SIZE) ? 1 : -1]; } | 59 _bytes_wide[(sizeof(CTYPENAME) == SIZE) ? 1 : -1]; } |
60 | 60 |
61 /* PP_COMPILE_ASSERT_SIZE_IN_BYTES is for typenames that contain no spaces. | 61 /* PP_COMPILE_ASSERT_SIZE_IN_BYTES is for typenames that contain no spaces. |
62 E.g.: | 62 E.g.: |
63 PP_COMPILE_ASSERT_SIZE_IN_BYTES(int, 4); | 63 PP_COMPILE_ASSERT_SIZE_IN_BYTES(int, 4); |
64 typedef struct { int a; } Foo; | 64 typedef enum { int a; } Foo; |
brettw
2010/11/24 22:36:40
What does declaring an int inside an enum mean? Wh
dmichael(do not use this one)
2010/11/24 23:23:15
I changed it to enum just because enums are more l
| |
65 PP_COMPILE_ASSERT_SIZE_IN_BYTES(Foo, 4); | 65 PP_COMPILE_ASSERT_SIZE_IN_BYTES(Foo, 4); |
66 */ | 66 */ |
67 #define PP_COMPILE_ASSERT_SIZE_IN_BYTES(NAME, SIZE) \ | 67 #define PP_COMPILE_ASSERT_SIZE_IN_BYTES(NAME, SIZE) \ |
68 PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, NAME, SIZE) | 68 PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, NAME, SIZE) |
69 | 69 |
70 /* PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES is for typenames that contain 'struct' | 70 /* PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES is for typenames that contain 'struct' |
71 in C. That is, struct names that are not typedefs. | 71 in C. That is, struct names that are not typedefs. |
72 E.g.: | 72 E.g.: |
73 struct Foo { int a; }; | 73 struct Foo { int a; }; |
74 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(Foo, 4); | 74 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(Foo, 4); |
75 */ | 75 */ |
76 #define PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(NAME, SIZE) \ | 76 #define PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(NAME, SIZE) \ |
77 PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, struct NAME, SIZE) | 77 PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, struct NAME, SIZE) |
78 | 78 |
79 /* PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES is for typenames that contain 'enum' | |
80 in C. That is, enum names that are not typedefs. | |
81 E.g.: | |
82 enum Foo { int a; }; | |
83 PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(Foo, 4); | |
84 */ | |
85 #define PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(NAME, SIZE) \ | |
86 PP_COMPILE_ASSERT_SIZE_IN_BYTES_IMPL(NAME, enum NAME, SIZE) | |
87 | |
79 /** | 88 /** |
80 * @} | 89 * @} |
81 * End of addtogroup PP | 90 * End of addtogroup PP |
82 */ | 91 */ |
83 | 92 |
84 #endif // PPAPI_C_PP_MACROS_H_ | 93 #endif // PPAPI_C_PP_MACROS_H_ |
85 | 94 |
OLD | NEW |