错误:的重新定义。 。 。作为不同种类的符号

时间:2018-12-18 01:55:35

标签: c++

我收到以下两个错误,并且我不知道如何解决ut_unixTimer.h标头文件中的代码。

在xap_CocoaTimer.cpp:28中包含的文件中:

  

../../../../ src / af / util / unix / ut_unixTimer.h:34:16:错误:重新定义   的         “ NSMutableDictionary”作为另一种符号类型定义结构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结构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 */

1 个答案:

答案 0 :(得分:0)

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

typedef struct NSMutableDictionary;
typedef struct NSLock;

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

typedef struct NSMutableDictionary OneAlias;
typedef struct NSLock AnotherAlias;

修正这些声明或完全消除它们,问题将消失。