首页 > 解决方案 > 错误:重新定义 . . . 作为不同种类的符号

问题描述

我收到以下两个错误,我不知道如何修复 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 */

标签: c++

解决方案


这是一对毫无意义的无效声明

typedef struct NSMutableDictionary;
typedef struct NSLock;

你想在这里做什么?这看起来像是试图声明 typedef-aliases 但实际的别名丢失了。如果您想为这些类型声明别名,则语法为

typedef struct NSMutableDictionary OneAlias;
typedef struct NSLock AnotherAlias;

修复这些声明或完全摆脱它们,问题就会消失。


推荐阅读