在OC的h头文件声明使用C++ class,不引用C++的h文件

来源:互联网 发布:怎样安装电脑软件 编辑:程序博客网 时间:2024/05/14 12:03

转自 :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

typedefvoid gp_mailer;

#endif

#endif


gp_mailer 定义在 google protobuf 协议的 gp_mailer.pb.h 文件中。由于用到C++,在mm文件包含这个头文件不会报错,但如果放到h文件,就会报错。

0 0
原创粉丝点击