summaryrefslogtreecommitdiff
path: root/include/openvswitch/util.h
diff options
context:
space:
mode:
authorShireesh Singh <shireeshcse07@gmail.com>2017-12-15 16:58:56 -0800
committerBen Pfaff <blp@ovn.org>2017-12-19 14:23:21 -0800
commit538372329b4caef36c8706cb90107a557cfce2ae (patch)
tree1c5020d8780962bb5f2101b7c095a9375ef1ccbb /include/openvswitch/util.h
parent99b09c637b0224e078211c8e0386f2c821674c28 (diff)
downloadopenvswitch-538372329b4caef36c8706cb90107a557cfce2ae.tar.gz
Windows: Fixing Windows C++ compilation issues with unnamed structure
MSVC does not allow to redefine unnamed structure in union. Thus, this fix defines the struct outside of the anonymous union in order to calculate the padded size. Signed-off-by: Shireesh Kumar Singh <shireeshkum@vmware.com> Co-authored-by:Sairam Venugopal <vsairam@vmware.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'include/openvswitch/util.h')
-rw-r--r--include/openvswitch/util.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/include/openvswitch/util.h b/include/openvswitch/util.h
index c3e60d561..ad1b184f7 100644
--- a/include/openvswitch/util.h
+++ b/include/openvswitch/util.h
@@ -185,11 +185,11 @@ OVS_NO_RETURN void ovs_assert_failure(const char *, const char *, const char *);
/* C++ doesn't allow a type declaration within "sizeof", but it does support
* scoping for member names, so we can just declare a second member, with a
* name and the same type, and then use its size. */
-#define PADDED_MEMBERS(UNIT, MEMBERS) \
- union { \
- struct { MEMBERS }; \
- struct { MEMBERS } named_member__; \
- uint8_t PAD_ID[ROUND_UP(sizeof named_member__, UNIT)]; \
+#define PADDED_MEMBERS(UNIT, MEMBERS) \
+ struct named_member__ { MEMBERS }; \
+ union { \
+ struct { MEMBERS }; \
+ uint8_t PAD_ID[ROUND_UP(sizeof(struct named_member__), UNIT)]; \
}
#endif
@@ -233,11 +233,11 @@ OVS_NO_RETURN void ovs_assert_failure(const char *, const char *, const char *);
}
#else
#define PADDED_MEMBERS_CACHELINE_MARKER(UNIT, CACHELINE, MEMBERS) \
+ struct struct_##CACHELINE { MEMBERS }; \
union { \
OVS_CACHE_LINE_MARKER CACHELINE; \
struct { MEMBERS }; \
- struct { MEMBERS } named_member_##CACHELINE; \
- uint8_t PAD_ID[ROUND_UP(sizeof named_member_##CACHELINE, UNIT)]; \
+ uint8_t PAD_ID[ROUND_UP(sizeof(struct struct_##CACHELINE), UNIT)]; \
}
#endif