- 论坛徽章:
- 0
|
在嵌入式开发中,一个用gcc编译通过的程序,用arm-elf-gcc编译却提示错误,下面是具体代码和错误提示
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include "datas.h"
#define SERV_ADDR "192.168.1.123"
#define SERV_PORT 12345
int main()
{
int sock=socket(AF_INET,SOCK_STREAM,0);
if(sock<0)
{
perror("creating socket error!");
exit(1);
}
struct sockaddr_in serv_addr;
/*
bzero(&serv_addr,sizeof(serv_addr));
serv_addr.sin_family=AF_INET;
if(inet_aton(SERV_ADDR,&serv_addr.sin_addr)<0)
{
perror("convert IP address error!");
exit(1);
}
serv_addr.sin_port=htons(SERV_PORT);
if(connect(sock,(struct sockaddr*)&serv_addr,sizeof(struct sockaddr_in))<0)
{
perror("connect to server error!");
exit(1);
}
struct card d;
int i,j=0;
while(j<10)
{
for(i=0;i<10;i++)
{
d.time[i] =48+j;
d.where[i] =48+j;
d.number[i]=48+j;
d.data[i] =48+j;
}
write(sock,(char*)&d,sizeof(struct card));
j++;
}
printf("%d messages has been send!\n",j);
close(sock);
*/
exit(0);
}
大部分代码都注释掉了,可就这么几句代码也提示有错,提示如下:
[root@super007 test]# arm-elf-gcc -c test.c
test.c: In function `main':
test.c:19: parse error before `struct'
求大家帮帮我吧,小第不胜感激!
网上没找到相关的资料,这是我的毕业设计啊,没多少天就要毕业了,时间很紧 |
|