2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

ofp-actions: Add compare to offsetof need for MSVC 2015/17

Unfortunately starting from VS 2015, the "C" definition for `offsetof`
has been changed. Please see:
https://stackoverflow.com/questions/42725929/using-offsetof-with-enum-does-not-compile-in-visual-studio-2015/42726424

Several people reported the bug for 2015 and also 2017 (i.e. :
https://developercommunity.visualstudio.com/content/problem/22196/static-assert-cannot-compile-constexprs-method-tha.html
), but we don't have a fix yet.

This patch adds an explicit compare, although we could redefine the macro
for the same effect.

Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Acked-by: Anand Kumar <kumaranand@vmware.com>
This commit is contained in:
Alin Gabriel Serdean
2017-11-01 19:19:07 +02:00
parent 2b3f8b6e23
commit 27f141d44d

View File

@@ -1128,7 +1128,7 @@ void *ofpact_finish(struct ofpbuf *, struct ofpact *);
BUILD_ASSERT_DECL(offsetof(struct STRUCT, ofpact) == 0); \
\
enum { OFPACT_##ENUM##_SIZE \
= (offsetof(struct STRUCT, MEMBER) \
= (offsetof(struct STRUCT, MEMBER) != 0 \
? offsetof(struct STRUCT, MEMBER) \
: OFPACT_ALIGN(sizeof(struct STRUCT))) }; \
\