转自 :http://stackoverflow.com/questions/10539424/properly-use-objective-c
//declare c++ impl for Obj-C++
#ifdef __cplusplus
class gp_mailer;
#endif
//declare obj-c impl
#ifdef __OBJC__
#ifndef __cplusplus
typedef void gp_mailer;
#endif
#endif
gp_mailer 定义在 google protobuf 协议的 gp_mailer.pb.h 文件中。由于用到C++,在mm文件包含这个头文件不会报错,但如果放到h文件,就会报错。
本文探讨了Objective-C与C++混合编程时的注意事项,特别是在类型定义与跨语言调用方面的问题。通过示例说明如何正确声明和使用来自Google Protocol Buffers的类,避免在不同编译单元间出现链接错误。

977

被折叠的 条评论
为什么被折叠?



