typedef重定义错误
来源:互联网 发布:淘宝店铺监控软件 编辑:程序博客网 时间:2024/05/29 13:18
记录一个问题。
Item.h文件:
typedef int Item;
Link.h文件:
#include "Item.h"
void LINKinit(int);
Link.c文件:
#include "stdio.h"
#include "Link.h"
#inlcude "Item.h"
void LINKint(int n)
{
printf("Create a new LINK.\n");
}
进行编译:gcc -o link.o -c Link.c出现如下错误:
In file included from Link.h:1,
from Link.c:2:
Item.h:1: 错误:typedef‘Item’重定义
Item.h:1: 附注:‘Item’的上一个声明在此
修改Item.h:
#ifndef __ITEM__
#define __ITEM__
typedef int Item;
#endif
这样就可以解决typedef重定义的问题。
这个在linux 2.6.32-220.el6.x86_64上运行 gcc4.4.6时出现。但是在F17(3.3.4-5.fc17.i686)上运行gcc4.7.2时没出现这个问题。
在网上找到一篇比较靠谱的解释,http://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=ce3765bf44e49ef0568a1ad4a0b7f807591d6412。
* c-decl.c (diagnose_mismatched_decls): Give error for duplicate
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> Sun, 23 May 2010 20:47:16 +0000 (20:47 +0000)committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> Sun, 23 May 2010 20:47:16 +0000 (20:47 +0000)
typedefs with different but compatible types. Allow duplicate
typedefs with the same type except for pedantic non-C1X, but give
warning for variably modified types.
typedefs with the same type except for pedantic non-C1X, but give
warning for variably modified types.
如果在编译时,加上-pedantic,则会有warning信息。
- typedef重定义错误
- 定义typedef struct 重定义错误解决办法
- 解决typedef重定义问题
- 链接重定义错误
- C2086 重定义错误
- link2005错误 .obj重定义
- 解决类重定义错误
- 关于类型重定义错误
- typedef定义
- C语言中重定义 错误
- winsock2.h中重定义错误解决方法
- 项目中的错误:默认参数重定义
- winsock2.h中重定义错误解决方法
- VS2008里 struct 类型重定义 错误
- VS2008里 struct 类型重定义 错误
- 编译器错误C2011类型重定义小记
- 对重定义错误的小小研究
- .h头文件出现重定义错误
- Xming + PuTTY 在Windows下远程Linux主机使用图形界面的程序
- C语言叙述-------开章
- 关于嵌入式x86平台tslib1.4+qt4.8.4移植
- 数据查询支持中文拼音首字母模糊检索
- 通用静态库的生成
- typedef重定义错误
- linux等待队列使用步骤
- 创建datatable
- 大数据处理三大瓶颈:大容量、多格式和速度
- 限制一个远程会话的用户(可用两种方法实现)
- Activity生命周期管理之一——Starting一个Activity
- 基本单链表实现
- C#多线程与UI响应 防界面假死
- 用C#比较字符串有多种方法