sizeof(struct sockaddr_storage) is smaller than sizeof(struct sockaddr_in6) #42945
-
My understanding is that sockaddr_storage must be >= sockaddr_in6 I am working on porting a network app and got a weird compiler error so I added the following to my code for test purposes (static analysis): char PATCH1[sizeof(struct sockaddr_storage) - sizeof(struct sockaddr_in6)]; char PATCH2[sizeof(struct sockaddr_in6) - sizeof(struct sockaddr_storage)]; The compiler tells me PATCH1 is too big, meaning we got a negative number. I am compiling with: west build -p auto -b native_posix_64 ....... |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Do you enable |
Beta Was this translation helpful? Give feedback.
-
Oops, no, sorry. That did the trick :-) |
Beta Was this translation helpful? Give feedback.
Do you enable
CONFIG_NET_IPV6
? If not,struct sockaddr_storage
will have a size ofstruct sockaddr_in
.