我是靠谱客的博主 幸福狗,这篇文章主要介绍typedef重定义错误,现在分享给大家,希望可以做个参考。

记录一个问题。


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时没

最后

以上就是幸福狗最近收集整理的关于typedef重定义错误的全部内容,更多相关typedef重定义错误内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(501)

评论列表共有 0 条评论

立即
投稿
返回
顶部