LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 693|回复: 1

main函数声明里有多个数据类型?

[复制链接]
发表于 2006-5-20 22:29:21 | 显示全部楼层 |阅读模式
我用命令gcc xxx.c -o xxx编译程序时出现提示:
xxx.c:8:two or more data types in declaration of 'main'
不知道是什么原因,希望解答,谢谢.
我的代码:
#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include "headers.h"

int main()
{
int sock, bytes_received, fromlen;
char buffer[65535];
struct sockaddr_in from;
struct ip *ip;
struct tcp *tcp;

sock=socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
while(1)
{
fromlen=sizeof from;
bytes_received=recvfrom(sock,buffer,sizeof buffer,
0,(struct sockaddr*)&from,&fromlen);
printf("\nByte_received:::%5d\n", bytes_received);
printf("Source address:::%s\n", inet_ntoa(from.sin_addr));
ip=(struct ip*)buffer;
printf("IP header length:::%d\n", ip->ip_length);
printf("rotocal:::%d\n",ip->ip_protocol);
tcp=(struct tcp*)(buffer+(4*ip->ip_length));
printf("Source port:::%d\n", ntohs(tcp->tcp_source_port));
}
return 0;
}
发表于 2006-5-25 16:05:37 | 显示全部楼层

我也是同样的问题

我在内核模块里,同样的程序,以前在fc3 linux-2.6.7上没有报错,现在在debian上编译就报同样的错误,我声明的那个函数是从内核导出的,extern int xxx(void);,现在出错了,请问这是什么原因造成的?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表