找回密码
 注册
查看: 800|回复: 5

奇怪的C语法错误

[复制链接]
发表于 2005-7-7 15:55:40 | 显示全部楼层 |阅读模式
源代码如下:
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <netinet/in.h>
#include <sys/msg.h>
#include <stdlib.h>
#include "tcp_ip.h"

#define MSG_KEY 1234

int a;
struct ppp_frame ppp_pack;
struct termios saved_attr;

void err_print(const char *);
int  open_port(void);
void reset_port_attr(void);
void set_port_attr( int);
void Byte2ppp_frame( int);

int main( void )
{
    ......

编译的时候提示:
link_layer.c:30: two or more data types in declaration of `a'
其实int a只不过是我随便定义的一个变量,后来我在int a前面又定义了
int b,编译的时候提示:
link_layer.c:30: two or more data types in declaration of `b'
这个很难理解,请问这是为什么呢?谢谢!
发表于 2005-7-7 16:10:06 | 显示全部楼层
该信息提示你的变量a和b都定义了两种以上不同的变量类型,可能哪地方符号打错了罢?
回复

使用道具 举报

 楼主| 发表于 2005-7-7 16:25:08 | 显示全部楼层
如果把前面的int a;去掉提示又变成:
link_layer.c:30: two or more data types in declaration of `ppp_pack'

这个很是困扰(刚才说的int a其实在程序中没有用到)
回复

使用道具 举报

发表于 2005-7-7 16:32:01 | 显示全部楼层
会不会是编译器坏了,,不过也不象
回复

使用道具 举报

发表于 2005-7-7 23:57:34 | 显示全部楼层
看是不是这个文件里有什么错误, "tcp_ip.h",你把包含这个文件的语句放在最前面试试,如果错误报到了一个系统的头文件里去了,则可以肯定错误是出在tcp_ip.h文件里了.
回复

使用道具 举报

 楼主| 发表于 2005-7-8 09:18:14 | 显示全部楼层
非常感谢楼上的仁兄,慧眼见第,一针见血,再次感谢你!!!
回复

使用道具 举报

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

本版积分规则

GMT+8, 2025-7-24 00:08 , Processed in 0.058390 second(s), 16 queries .

© 2001-2025 Discuz! Team. Powered by Discuz! X3.5.

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