我正在尝试在objective-c中包装gloox库。我读过这篇文章Making a Objective-C Wrapper for a C++ Library,它非常简单明了,但是它并没有涵盖名称空间中的类。关于如何将上述文章中的技术仅用于命名空间,您有什么想法吗?谢谢你的帮助!
编辑我想我弄明白了
#ifdef __cplusplus
namespace gloox {
class Client;
}
#endif发布于 2011-08-31 22:58:20
我认为当编译为objective 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
@endQt项目有很多用于混合C++和Objective-C的examples。
https://stackoverflow.com/questions/7258549
复制相似问题