繁体   English   中英

命名空间C ++库的Objective-C包装器(gloox)

[英]objective-c wrapper for namespaced c++ library (gloox)

我试图将gloox库包装在Objective-C中。 我已经读过这篇文章《为C ++库制作Objective-C包装器》 ,这很简单,但是没有涵盖名称空间中的类。 关于如何仅在名称空间中使用以上文章中的技术的任何想法? 谢谢您的帮助!

[编辑]认为我想通了添加

#ifdef __cplusplus
namespace gloox {
class Client;
}
#endif

我认为当编译为目标C ++时,显而易见的方法应该起作用:

#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的示例

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM