C编译错误
问题描述:
编译时以下错误的含义是什么?C编译错误
Tilemap.h:21: error: conflicting types for ‘ThreeDWorld’
Tilemap.h:21: error: previous declaration of ‘ThreeDWorld’ was here
Tilemap.h:29: error: conflicting types for ‘CGPoint’
Tilemap.h:29: error: previous declaration of ‘CGPoint’ was here
Tilemap.h:31: error: conflicting types for ‘tileForCoordinates’
Tilemap.h:31: error: previous declaration of ‘tileForCoordinates’ was here
为什么它给了什么呢?我的源文件有它的一个实例是这样
typedef struct
{
int xPosition;
int yPosition;
}
CGPoint;
答
沾些包容守卫你的头。
您的类型定义在您的编译单元中出现多次。
答
您包含头文件两次。
在我自己的代码,我包的所有头文件与
#ifndef HEADER_FILE_NAME
#define HEADER_FILE_NAME
#endif
,以避免此类错误。
你是否偶然使用Obj-C和XCODE? – 2011-04-05 16:38:38
Textmate和Terminal – jarryd 2011-04-05 16:48:14