编译时,以下错误意味着什么。
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;发布于 2011-04-06 00:28:07
您是否包含来自多个位置的头文件?如果是,请在头文件中使用防护。
例如,在Tilemap.h中:
#ifndef TILEMAP_H
#define TILEMAP_H
// header file contents
#endif /* TILEMAP_H */发布于 2011-04-06 00:28:15
在你的头上贴上一些包含性保护。
您的类型定义在编译单元中出现多次。
发布于 2011-04-06 00:28:31
您包含了两次头文件。
在我自己的代码中,我用
#ifndef HEADER_FILE_NAME
#define HEADER_FILE_NAME
#endif来避免这样的错误。
https://stackoverflow.com/questions/5555148
复制相似问题