首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >命名空间c++库的objective-c包装器(gloox)

命名空间c++库的objective-c包装器(gloox)
EN

Stack Overflow用户
提问于 2011-08-31 22:33:28
回答 1查看 529关注 0票数 0

我正在尝试在objective-c中包装gloox库。我读过这篇文章Making a Objective-C Wrapper for a C++ Library,它非常简单明了,但是它并没有涵盖名称空间中的类。关于如何将上述文章中的技术仅用于命名空间,您有什么想法吗?谢谢你的帮助!

编辑我想我弄明白了

代码语言:javascript
复制
#ifdef __cplusplus
namespace gloox {
class Client;
}
#endif
EN

回答 1

Stack Overflow用户

发布于 2011-08-31 22:58:20

我认为当编译为objective C++时,显而易见的事情应该是有效的:

代码语言:javascript
复制
#if defined __cplusplus
namespace Foo { class MyCPPClass; }   // forward class declaration
#else
/*not sure here*/ /*namespace Foo { typedef struct MyCPPClass MyCPPClass;  }*/ // forward struct declaration
#endif

@interface MyOCClass : NSObject
{
@private
    Foo::MyCPPClass* cppObject;
} 

// methods and properties

@end

Qt项目有很多用于混合C++和Objective-C的examples

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7258549

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档