summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2017-07-10 21:55:56 -0700
committerBen Pfaff <blp@ovn.org>2017-07-13 10:24:06 -0700
commit4fe660719dde3def2eb2e427e1313e03c4a8066f (patch)
tree7a295ce6c9311e341f71437124447c766c410f0a /include
parent8a8c1b93b1723e022665950ec0b623dc6b57fbb0 (diff)
downloadopenvswitch-4fe660719dde3def2eb2e427e1313e03c4a8066f.tar.gz
util: Make PADDED_MEMBERS work more than once per struct.
Until now, if the PADDED_MEMBERS macro was used more than once in a struct, it caused Clang and GCC warnings because of multiple definition of a member named "pad". This commit fixes the problem by giving each of these a unique name. MSVC, Clang, and GCC all support the __COUNTER__ macro, although it is not standardized. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Bhanuprakash Bodireddy <Bhanuprakash.bodireddy@intel.com>
Diffstat (limited to 'include')
-rw-r--r--include/openvswitch/util.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/openvswitch/util.h b/include/openvswitch/util.h
index 8453550cd..17b06528f 100644
--- a/include/openvswitch/util.h
+++ b/include/openvswitch/util.h
@@ -172,10 +172,13 @@ OVS_NO_RETURN void ovs_assert_failure(const char *, const char *, const char *);
* PADDED_MEMBERS(8, uint8_t x; uint8_t y;);
* };
*/
+#define PAD_PASTE2(x, y) x##y
+#define PAD_PASTE(x, y) PAD_PASTE2(x, y)
+#define PAD_ID PAD_PASTE(pad, __COUNTER__)
#define PADDED_MEMBERS(UNIT, MEMBERS) \
union { \
struct { MEMBERS }; \
- uint8_t pad[ROUND_UP(sizeof(struct { MEMBERS }), UNIT)]; \
+ uint8_t PAD_ID[ROUND_UP(sizeof(struct { MEMBERS }), UNIT)]; \
}
static inline bool