当前位置: 技术问答>linux和unix
一个简单的c代码编译不过的问题。
来源: 互联网 发布时间:2014-12-18
本文导语: 我的代码编译不过。 代码如下: #include #include int main() { int sockfd; struct sockaddr_in my_addr; //line 10 memset(&my_addr,0,sizeof(struct sockaddr_in)); //line 11 ...
我的代码编译不过。
代码如下:
#include
#include
int main()
{
int sockfd;
struct sockaddr_in my_addr; //line 10
memset(&my_addr,0,sizeof(struct sockaddr_in)); //line 11
.................
return 0;
}
编译信息为:
gcc -g -Wall -O3 -MD -c -o nettest.o nettest.c
nettest.c: In function `main':
nettest.c:10: storage size of `my_addr' isn't known
nettest.c:11: sizeof applied to an incomplete type
nettest.c:11: sizeof applied to an incomplete type
nettest.c:11: sizeof applied to an incomplete type
nettest.c:11: sizeof applied to an incomplete type
nettest.c:11: sizeof applied to an incomplete type
nettest.c:11: sizeof applied to an incomplete type
请教一下各位,这是个什么错?该如何解决?谢谢。
代码如下:
#include
#include
int main()
{
int sockfd;
struct sockaddr_in my_addr; //line 10
memset(&my_addr,0,sizeof(struct sockaddr_in)); //line 11
.................
return 0;
}
编译信息为:
gcc -g -Wall -O3 -MD -c -o nettest.o nettest.c
nettest.c: In function `main':
nettest.c:10: storage size of `my_addr' isn't known
nettest.c:11: sizeof applied to an incomplete type
nettest.c:11: sizeof applied to an incomplete type
nettest.c:11: sizeof applied to an incomplete type
nettest.c:11: sizeof applied to an incomplete type
nettest.c:11: sizeof applied to an incomplete type
nettest.c:11: sizeof applied to an incomplete type
请教一下各位,这是个什么错?该如何解决?谢谢。
|
加上
#include
试试看
#include
试试看
|
memset(&my_addr,0,sizeof(struct sockaddr_in));
改为
memset(&my_addr,0,sizeof(my_addr));
改为
memset(&my_addr,0,sizeof(my_addr));