Reputation: 63
In my C-code I've got a tcpsock.c and tcpsock.h file. The tpcsock.c file include's the tcpsock.h file. This socketcode is used in a connmgr.c (which includes tcpsock.c). In the C file I've got two structs, which are defined as follows:
struct tcpsock{
long cookie;
int sd;
char * ip_addr;
int port;
};
struct conn{
struct tcpsock_t socket;
long last_active;
};
In the header file I have the following code:
typedef struct tcpsock tcpsock_t;
typedef struct conn conn_t;
When I try to compile this, I'm getting the following error:
In file included from connmgr.c:12:0:
lib/tcpsock.c:78:22: error: field ‘socket’ has incomplete type
struct tcpsock_t socket;
^
I've been searching everywhere but wasn't able to find a solution, so I hope anyone here can help me. Thanks in advance!
Upvotes: 0
Views: 6418
Reputation: 1025
typedef struct tcpsock tcpsock_t;
defines tcpsock_t
as a struct tcpsock
. Hence, your struct definition must look like this:
struct conn{
tcpsock_t socket;
long last_active;
};
Upvotes: 8