oc 调用c cpp

1、 天生兼容 c

 直接在.m里include就行

 

2、调用cpp

需要先把调用的文件名由.m改成.mm

#include "TestOne.hpp"


int res = TestOne::getOne()+getmya();
NSString* str = [NSString
                    stringWithFormat:@"%d",res];
self.lbResult.text =str;

.mm 文件引用c好像不行

可以在cpp头文件里用 extern "C" 引入

extern "C"{

  #include  "testc.h"

}

文件目录如下

 

posted @ 2022-02-01 22:12  cnchengv  阅读(129)  评论(0编辑  收藏  举报