Advertisement

GCC 3.2 bug?

Started by November 13, 2002 05:02 PM
4 comments, last by NuffSaid 21 years, 11 months ago

  
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>


int main(void) {
	struct sockaddr_in address;
	sizeof(sockaddr);
	
	return 0;	
}  
The above code compiles fine on GCC 2.9x, but it doesn''t compile on GCC 3.2. It says that it can''t determine the size of sockaddr. If I replace sockaddr with address, I get the same error message. But it compiles fine in GCC 2.9x. Any ideas?
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
maybe "sizeof(struct sockaddr);" ?
Advertisement
Whoops, that''s a typo. It does say struct sockaddr in my C file. Says that length of address isn''t known at compile time.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
Now sizeof(struct sockaddr) works!

Where do I find the definition of all unix structures? I can''t find the definition of sockaddr_in anywhere.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
All of the socket structures are in netinet/in.h

This should do what you want -


  #include <sys/socket.h>#include <netinet/in.h>int main(void) {	struct sockaddr_in address;	sizeof(struct sockaddr_in);	return 0;}  
That''s cool, but why didn''t I need it in GCC 2.9x? Oh well, as long as it works now.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.

This topic is closed to new replies.

Advertisement