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

时间:2010-04-29 16:58:45

标签: c++ iphone objective-c header integration

我已经制作了一个模板应用程序,我已经抓住了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'

知道这里发生了什么吗?

干杯

的Nik

1 个答案:

答案 0 :(得分:5)

您间接地将C ++标头包含在普通的Objective-C代码(.m)中 - 这不起作用,您必须一直使用Objective-C++.mm)或使用opaque pointers在Objective-C类中封装C ++类。

一个有问题的链条:

  • Classes/MainViewController.m,简单的Objective-C,包括
  • RecorderLink.h,包括
  • AQRecorder.h,即C ++