gpt4 book ai didi

C 编译错误

转载 作者:太空宇宙 更新时间:2023-11-04 00:27:08 24 4
gpt4 key购买 nike

编译时出现如下错误是什么意思。

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;

最佳答案

您是否包含来自多个地方的头文件?如果是这样,请在头文件中使用保护。

例如,在 Tilemap.h 中:

 #ifndef TILEMAP_H
#define TILEMAP_H

// header file contents

#endif /* TILEMAP_H */

关于C 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5555148/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com