2010-11-22 62 views
0

我想從目標C調用CPP函數。我已經在CPP中編寫了函數。我試圖從test.mm文件中調用CPP函數,但我收到以下錯誤消息。CPP與目標C的集成

錯誤:「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) 
{ 
...... 
...... 
}
+2

請過帳一些代碼。 – xxpor 2010-11-22 13:42:23

+0

'MergeAudioFiles.h'中有什麼? – 2010-11-22 13:53:12

+0

MergeAudioFiles.h就像testCPP.h – jfalexvijay 2010-11-22 13:55:38

回答

1

您是否 #include "testCPP.h"

函數需要在MergeAudioFiles.h中聲明,就像在普通的C++中一樣。

+0

是的,我已包括在內。 – jfalexvijay 2010-11-22 13:45:04