来自iPhone应用程序中的SpeakHere的C++

nik*_*ers 4 c++ iphone integration header objective-c

我已经制作了一个模板应用程序,我已经抓住了SpeakHere示例的录制部分并删除了文件处理部分,但我很难让应用程序的C++部分正常工作.一旦进入C++类,就会出现语法错误.如果我不从C++导入头文件(然后当然不使用代码)到我的Objective C类中,一切正常.我看不出我在做什么和示例是这样做的区别.你能看到区别么?

我在这里发布了整个代码:http://github.com/niklassaers/testFFT

我得到的构建错误是:

testFFT/CAStreamBasicDescription.h:91:0 testFFT/CAStreamBasicDescription.h:91: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CAStreamBasicDescription'
testFFT/CAStreamBasicDescription.h:298:0 testFFT/CAStreamBasicDescription.h:298: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
testFFT/CAStreamBasicDescription.h:299:0 testFFT/CAStreamBasicDescription.h:299: error: expected '=', ',', ';', 'asm' or '__attribute__' before '==' token
testFFT/CAStreamBasicDescription.h:301:0 testFFT/CAStreamBasicDescription.h:301: error: expected '=', ',', ';', 'asm' or '__attribute__' before '!=' token
testFFT/CAStreamBasicDescription.h:302:0 testFFT/CAStreamBasicDescription.h:302: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<=' token
testFFT/CAStreamBasicDescription.h:303:0 testFFT/CAStreamBasicDescription.h:303: error: expected '=', ',', ';', 'asm' or '__attribute__' before '>=' token
testFFT/CAStreamBasicDescription.h:304:0 testFFT/CAStreamBasicDescription.h:304: error: expected '=', ',', ';', 'asm' or '__attribute__' before '>' token
testFFT/CAStreamBasicDescription.h:307:0 testFFT/CAStreamBasicDescription.h:307: error: expected ';', ',' or ')' before '&' token
testFFT/CAXException.h:65:0 testFFT/CAXException.h:65: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CAX4CCString'
testFFT/CAXException.h:87:0 testFFT/CAXException.h:87: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'CAXException'
testFFT/AQRecorder.h:59:0 testFFT/AQRecorder.h:59: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'AQRecorder'
testFFT/RecorderLink.h:57:0 testFFT/RecorderLink.h:57: error: expected specifier-qualifier-list before 'AQRecorder'
testFFT/RecorderLink.h:62:0 testFFT/RecorderLink.h:62: error: expected specifier-qualifier-list before 'AQRecorder'
Run Code Online (Sandbox Code Playgroud)

知道这里发生了什么吗?

干杯

Geo*_*che 5

您间接地将C++标头包含在普通的Objective-C代码(.m)中 - 这是行不通的,您必须一直使用Objective-C++(.mm)或使用不透明指针将C++类封装在Objective-C类中.

一个有问题的链:

  • Classes/MainViewController.m,plain Objective-C,包括
  • RecorderLink.h包括
  • AQRecorder.h,这是C++