Skip to content

Commit 4d8ffcc

Browse files
adigiekartben
authored andcommitted
net: if: Add dummy member to anonymous union in net_if_addr
When both CONFIG_NET_IPV6_DAD and CONFIG_NET_IPV4_ACD are disabled, the anonymous union in struct net_if_addr ends up with no members, which results in a different struct layout between C and C++. In C, an empty union has size 0, while in C++ it has size >=1, which shifts the offsets of the following fields. Add a 1-byte dummy member to the union to ensure consistent layout across both compilers. Signed-off-by: Adrian Gielniewski <[email protected]>
1 parent d265dad commit 4d8ffcc

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

include/zephyr/net/net_if.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ struct net_if_addr {
125125
uint8_t acd_state;
126126
};
127127
#endif /* CONFIG_NET_IPV4_ACD */
128+
uint8_t _dummy;
128129
};
129130

130131
#if defined(CONFIG_NET_IPV6_DAD) || defined(CONFIG_NET_IPV4_ACD)

0 commit comments

Comments
 (0)