typedef struct CLIENT{ int fd; char *name; struct sockaddr_in addr; char *data; }; void process_cli(CLIENT *client,char *recvbuf,int len); void savedata(char *recvbuf,int len,char *data); main(){ int i,maxi,maxfd,sockfd; int nready; ssize_t n; fd_setrset,allset; int listenfd,connectfd; struct sockaddr_in server; CLIENT client[FD_SETSIZE]; char recvbuf[MAXDATASIZE];
编译的时候提示:
c:22:1: warning: useless storage class specifier in empty declaration
};
^
iotcpserver.c:23:18: error: unknown type name ‘CLIENT’
void process_cli(CLIENT *client,char *recvbuf,int len);
^
iotcpserver.c:26:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
main(){
^
iotcpserver.c: In function ‘main’:
iotcpserver.c:30:2: error: ‘fd_setrset’ undeclared (first use in this function)
fd_setrset,allset;
^
iotcpserver.c:30:2: note: each undeclared identifier is reported only once for each function it appears in
iotcpserver.c:30:13: error: ‘allset’ undeclared (first use in this function)
fd_setrset,allset;
^
iotcpserver.c:33:2: error: unknown type name ‘CLIENT’
CLIENT client[FD_SETSIZE];
^
iotcpserver.c:60:12: error: request for member ‘fd’ in something not a structure or union
client[i].fd=-1;
^
iotcpserver.c:67:3: error: ‘rset’ undeclared (first use in this function)
rset=allset;
^
iotcpserver.c:76:17: error: request for member ‘fd’ in something not a structure or union
if(client[i].fd<0){
^
iotcpserver.c:77:15: error: request for member ‘fd’ in something not a structure or union
client[i].fd=connectfd;
^
iotcpserver.c:78:15: error: request for member ‘name’ in something not a structure or union
client[i].name=new char[MAXDATASIZE];
^
iotcpserver.c:78:21: error: ‘new’ undeclared (first use in this function)
client[i].name=new char[MAXDATASIZE];
^
iotcpserver.c:78:25: error: expected ‘;’ before ‘char’
client[i].name=new char[MAXDATASIZE];
^
iotcpserver.c:79:15: error: request for member ‘addr’ in something not a structure or union
client[i].addr=addr;
^
iotcpserver.c:80:15: error: request for member ‘data’ in something not a structure or union
client[i].data=new char[MAXDATASIZE];
^
iotcpserver.c:80:25: error: expected ‘;’ before ‘char’
client[i].data=new char[MAXDATASIZE];
^
怎么解决啊?
qq_莫非
望远
慕移动6052691
onemoo