The variable has an incomplete type 'struct sockaddr_in'

I'm trying to use

struct sockaddr_in sin; 

but if i use this i get

 Variable has incomplete type 'struct sockaddr_in' 

and

 Forward declaration of 'struct sockaddr_in' 

like a mistake. I get an error when I use Xcode4. In Xcode3.2, it works. Does anyone know how to solve this error? My import

 #import <sys/socket.h> #import <netinet/in.h> #import <netinet6/in6.h> #import <arpa/inet.h> #import <ifaddrs.h> #include <netdb.h> #import <SystemConfiguration/SCNetworkReachability.h> 
+4
source share
2 answers

Have you linked your target to these two libraries?

  • CFNetwork
  • Systemconfiguration

enter image description here

+3
source

Try using #import rather #include . #import ensures you never have a recursive inclusion problem.

Tried and succeeded in Xcode 9.0.1, obj C. iOS 11

 -SN 
+1
source

Source: https://habr.com/ru/post/1392431/


All Articles