Skip to content

Commit

Permalink
openvswitch/types.h: Drop the member name in initializer macro
Browse files Browse the repository at this point in the history
MSVC++ compiler does not allow initializing a struct while
explicitly initializing a member in the struct.

Not allowed:
    static const struct eth_addr a = {{ .ea= { 0xff, 0xff, 0xff, 0xff,
                                        0xff, 0xff }}};

Alowed:
    static const struct eth_addr b  = {{{ 0xff, 0xff, 0xff, 0xff, 0xff,
                                          0xff }}};
*An extra curly brace is required for GCC in case the struct contains
a union.

Signed-off-by: Shashank Ram <rams@vmware.com>
Tested-by: Yi-Hung Wei <yihung.wei@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
  • Loading branch information
Shashank Ram authored and blp committed Jan 25, 2018
1 parent 48bcbcc commit 66bab9c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions include/openvswitch/types.h
Expand Up @@ -171,7 +171,7 @@ struct eth_addr {
/* Ethernet address constant, e.g. ETH_ADDR_C(01,23,45,67,89,ab) is
* 01:23:45:67:89:ab. */
#define ETH_ADDR_C(A,B,C,D,E,F) \
{ { .ea = { 0x##A, 0x##B, 0x##C, 0x##D, 0x##E, 0x##F } } }
{ { { 0x##A, 0x##B, 0x##C, 0x##D, 0x##E, 0x##F } } }

/* Similar to struct eth_addr, for EUI-64 addresses. */
struct eth_addr64 {
Expand All @@ -184,8 +184,7 @@ struct eth_addr64 {
/* EUI-64 address constant, e.g. ETH_ADDR_C(01,23,45,67,89,ab,cd,ef) is
* 01:23:45:67:89:ab:cd:ef. */
#define ETH_ADDR64_C(A,B,C,D,E,F,G,H) \
{ { .ea64 = { 0x##A, 0x##B, 0x##C, 0x##D, \
0x##E, 0x##F, 0x##G, 0x##H} } }
{ { { 0x##A, 0x##B, 0x##C, 0x##D, 0x##E, 0x##F, 0x##G, 0x##H } } }

#ifdef __cplusplus
}
Expand Down

0 comments on commit 66bab9c

Please sign in to comment.