c++ - 错误:重新定义 . . . 作为不同种类的符号
问题描述
我收到以下两个错误,我不知道如何修复 ut_unixTimer.h 头文件中的代码。
在 xap_CocoaTimer.cpp:28 包含的文件中:
../../../../src/af/util/unix/ut_unixTimer.h:34:16:错误:将“NSMutableDictionary”重新定义为不同类型的符号 typedef struct NSMutableDictionary;^ /System/Library/Frameworks/AppKit.framework/Headers/NSPageController.h:16:8: 注意:之前的定义在这里@class NSMutableDictionary, NSView; ^
在 xap_CocoaTimer.cpp:28 包含的文件中:
../../../../src/af/util/unix/ut_unixTimer.h:35:16:错误:将“NSLock”重新定义为不同类型的符号 typedef struct NSLock;^ /System/Library/Frameworks/AppKit.framework/Headers/NSDrawer.h:19:8: 注意:之前的定义在这里@class NSLock;
ut_unixTimer.h
:
#ifndef UT_UNIXTIMER_H
#define UT_UNIXTIMER_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ut_timer.h"
#ifdef TOOLKIT_COCOA
typedef struct NSMutableDictionary;
typedef struct NSLock;
#endif
class UT_UNIXTimer : public UT_Timer
{
public:
UT_UNIXTimer(UT_WorkerCallback pCallback, void* pData);
virtual ~UT_UNIXTimer();
virtual UT_sint32 set(UT_uint32 iMilliseconds);
virtual void stop();
virtual void start();
private:
typedef UT_sint32 millisec_t;
millisec_t m_iMilliseconds;
UT_uint32 m_iGtkTimerId;
#ifdef TOOLKIT_COCOA
/* these are here for Cocoa timer */
static NSLock* s_timerMutex;
static NSMutableDictionary* s_timerIds;
static int s_lastTimerId;
friend void _checkLock(void);
friend void XAP_stopCocoaTimer (UT_uint32 timerId);
friend UT_uint32 XAP_newCocoaTimer (UT_uint32 time, int (*proc)(void *), void *p);
#endif
};
#endif /* UT_UNIXTIMER_H */
解决方案
这是一对毫无意义的无效声明
typedef struct NSMutableDictionary;
typedef struct NSLock;
你想在这里做什么?这看起来像是试图声明 typedef-aliases 但实际的别名丢失了。如果您想为这些类型声明别名,则语法为
typedef struct NSMutableDictionary OneAlias;
typedef struct NSLock AnotherAlias;
修复这些声明或完全摆脱它们,问题就会消失。
推荐阅读
- sql - 站点代码匹配的所有字段 A 的总和
- pandas - Pandas 中最大值的位置
- javascript - 不通过磁力链接下载文件
- google-bigquery - 对 create_if_needed 和 write_append 的 bigquery 查询或 ddl 语句
- azure - 应用服务计划未列出 Azure 门户中的所有应用
- mysql - 是否可以有条件地计算这个 mysql 表
- python - Pandas Df - 将一个值更改为大写
- bash - 排除 0 个大小的文件
- java - 如何在我的 Java 代码中找到问题?
- elasticsearch - 如何在弹性搜索索引中检索所有文档(大小大于 10000)