0

如何在 Objective-C++ 中导入 Objective-C 标头?

这是标题:

typedef struct _xmlDoc xmlDoc;
typedef struct _xmlNs xmlNs;
typedef struct _xmlAttr xmlAttr;
typedef struct _xmlNode {
    void* _field1;
    int _field2;
    char* _field3;
    struct xmlNode* _field4;
    struct xmlNode* _field5;
    struct xmlNode* _field6;
    struct xmlNode* _field7;
    struct xmlNode* _field8;
    xmlDoc* _field9;
    xmlNs* _field10;
    char* _field11;
    xmlAttr* _field12;
    xmlNs* _field13;
    void* _field14;
    unsigned short _field15;
    unsigned short _field16;
} xmlNode;

typedef struct _xmlDict xmlDict;
typedef struct _xmlDtd xmlDtd;
struct _xmlDoc {
    void* _field1;
    int _field2;
    char* _field3;
    struct xmlNode* _field4;
    struct xmlNode* _field5;
    struct xmlNode* _field6;
    struct xmlNode* _field7;
    struct xmlNode* _field8;
    struct xmlDoc* _field9;
    int _field10;
    int _field11;
    struct xmlDtd* _field12;
    struct xmlDtd* _field13;
    struct xmlNs* _field14;
    char* _field15;
    char* _field16;
    void* _field17;
    void* _field18;
    char* _field19;
    int _field20;
    struct xmlDict* _field21;
    void* _field22;
    int _field23;
    int _field24;
};

struct _xmlNs {
    struct xmlNs* _field1;
    int _field2;
    char* _field3;
    char* _field4;
    void* _field5;
    struct xmlDoc* _field6;
};

struct _xmlAttr {
    void* _field1;
    int _field2;
    char* _field3;
    struct xmlNode* _field4;
    struct xmlNode* _field5;
    struct xmlNode* _field6;
    struct xmlAttr* _field7;
    struct xmlAttr* _field8;
    struct xmlDoc* _field9;
    struct xmlNs* _field10;
    int _field11;
    void* _field12;
};

struct _xmlDtd;

struct _xmlDict;

typedef struct sqlite3 sqlite3;

typedef struct sqlite3_stmt sqlite3_stmt;

编译我的项目时,它会引发以下错误:

Structs.h:49:3: error: typedef redefinition with different types ('struct _xmlNode' vs 'xmlNode')
} xmlNode;
  ^
Structs.h:36:9: note: previous definition is here
        struct xmlNode* _field4;
               ^
Structs.h:62:9: error: elaborated type refers to a typedef
        struct xmlDoc* _field9;
               ^
Structs.h:29:24: note: declared here
typedef struct _xmlDoc xmlDoc;
                       ^
Structs.h:65:9: error: elaborated type refers to a typedef
        struct xmlDtd* _field12;
               ^
Structs.h:52:24: note: declared here
typedef struct _xmlDtd xmlDtd;
                       ^
Structs.h:67:9: error: elaborated type refers to a typedef
        struct xmlNs* _field14;
               ^
Structs.h:30:23: note: declared here
typedef struct _xmlNs xmlNs;
                      ^
Structs.h:74:9: error: elaborated type refers to a typedef
        struct xmlDict* _field21;
               ^
Structs.h:51:25: note: declared here
typedef struct _xmlDict xmlDict;
                        ^
Structs.h:81:9: error: elaborated type refers to a typedef
        struct xmlNs* _field1;
               ^
Structs.h:30:23: note: declared here
typedef struct _xmlNs xmlNs;
                      ^
Structs.h:86:9: error: elaborated type refers to a typedef
        struct xmlDoc* _field6;
               ^
Structs.h:29:24: note: declared here
typedef struct _xmlDoc xmlDoc;
                       ^
Structs.h:96:9: error: elaborated type refers to a typedef
        struct xmlAttr* _field7;
               ^
Structs.h:31:25: note: declared here
typedef struct _xmlAttr xmlAttr;
                        ^
Structs.h:98:9: error: elaborated type refers to a typedef
        struct xmlDoc* _field9;
               ^
Structs.h:29:24: note: declared here
typedef struct _xmlDoc xmlDoc;
                       ^
Structs.h:99:9: error: elaborated type refers to a typedef
        struct xmlNs* _field10;
               ^
Structs.h:30:23: note: declared here
typedef struct _xmlNs xmlNs;

这不是因为标题是用Objective-C编写的吗?

4

1 回答 1

3

是的,问题是你没有定义任何 type struct xmlNode。你有一个 typestruct _xmlNode和一个 type xmlNode,但没​​有struct xmlNodestruct xmlNode您可以用xmlNode或替换所有实例struct _xmlNode

于 2012-05-09T15:32:09.650 回答