CPP与目标C的整合

时间:2010-11-22 13:40:02

标签: c++ objective-c

我想从Objective C调用CPP函数。我已经在CPP中编写了该函数。我试图从test.mm文件调用CPP函数,但我收到以下错误消息。

错误:未在此范围内声明'functionName'

我在testCPP.cpp&中编写了函数'functionName'。 testCPP.h

请帮我解决。

//Objective-C (.mm)
#import "MergeAudios.h"
#import "MergeAudioFiles.h" // cpp header file

@implementation MergeAudios

-(void)mergeAudioFile1:(CFURLRef)path1 file2:(CFURLRef)path2 withFile:(CFURLRef)path3{
    CombineAudioFiles(path1, path2, path3);
}

@end
// CPP (.cpp)

void CombineAudioFiles(CFURLRef sourceURL1, CFURLRef sourceURL2, CFURLRef destinationURL) 
{
......
......
}

1 个答案:

答案 0 :(得分:1)

你有#include "testCPP.h"吗?

函数需要在MergeAudioFiles.h中声明,就像在普通的C ++中一样。