declared struct compiles as 'undeclared'

I have a program (main.c) that includes the header rpc/rpc.h which includes the header netinet/in.h which contains the header cygwin/in.h which contains the struct "sockaddr_in":

1
2
3
4
5
6
7
8
9
10
struct sockaddr_in
{
    sa_family_t	 sin_family;	/* Address family		*/
    in_port_t	 sin_port;	/* Port number			*/
    struct in_addr sin_addr;	/* Internet address		*/

    /* Pad to size of `struct sockaddr'. */
    unsigned char  __pad[__SOCK_SIZE__ - sizeof(short int)
			- sizeof(unsigned short int) - sizeof(struct in_addr)];
};


For some reason when I try to compile it this happens:

$ gcc-3.exe -Wall -O2 -IC:/cygwin/usr/include/tirpc -IC:/cygwin/usr/include -c C:/cygwin/home/eb/rap00/main.c -o obj/Release/main.o
C:/cygwin/home/eb/rap00/main.c: In function `main':
C:/cygwin/home/eb/rap00/main.c:50: error: `sockaddr_in' undeclared (first use in this function)
C:/cygwin/home/eb/rap00/main.c:50: error: (Each undeclared identifier is reporte d only once
C:/cygwin/home/eb/rap00/main.c:50: error: for each function it appears in.)
C:/cygwin/home/eb/rap00/main.c:50: error: `addr' undeclared (first use in this f unction)
C:/cygwin/home/eb/rap00/main.c:53: warning: implicit declaration of function `in et_pton'

The offending line is this:

sockaddr_in *addr;

Why is GCC choking?

Last edited on
Maybe you have to write struct sockaddr_in *addr;
well, um, I don't know if this is simple a C&P issue, but that doesn't define a struct:

 
truct sockaddr_in


It's missing the 's'. If this is not a C&P error, then I'm surprised your compiler didn't choke earlier on a unidentified keyword.
The "s" was there. Must've "dropped" it during the cut and paste.
Found a workaround.

This question is moot.
Topic archived. No new replies allowed.