Jump to content
  • Advertisement
Sign in to follow this  
Tuggle

Work in Windows no Linux

This topic is 4849 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

struct connection {
#ifdef WIN32
	WSADATA wsaData;
	SOCKET socket1;
#else
	int socket1;
#endif
	struct sockaddr_in dest_addr;
	struct hostent *hostentry;
	char *ip;
	int port;
	int state;

};

That structure I use. In Windows I can compile my code fine but in Linux I get: error: defrencing point to incomplete type for this piece of code:
conn->dest_addr.sin_addr = *( ( struct sockaddr_in * )conn->hostentry->h_addr_list[0] ); 
but it compile in window idea?

Share this post


Link to post
Share on other sites
Advertisement
You didn't include the header that defines sockaddr_in on Linux.

Note: the WSADATA is only needed on startup, so you don't need to hang on to it in the "connection" struct. Also, on Linux, you can #define SOCKET to int, so your struct doesn't need to be ifdefed at all.

Share this post


Link to post
Share on other sites
I would prefer typedef int SOCKET over #define SOCKET int, but you can tell me why I'm wrong if you like?

Share this post


Link to post
Share on other sites
I have vague recollections of trying that first (I'm usually a typedef man), and it failing in some unexpected gotcha, but I couldn't tell you what -- haven't had to change my portability layer for a while now ;-)

If you typedef and it works, so much the better.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!