简体   繁体   English

Apple的SpeakHere演示,混合了ObjC和C ++,以及翻译单元

[英]Apple's SpeakHere demo, mixing ObjC and C++, and translation units

Using Apple's SpeakHere demo as starting point, I want to implement a sound waveform instead of a level meter. 以苹果公司的SpeakHere演示为起点,我想实现一个声音波形而不是一个电平表。 I added another view, SoundWaveView, an ObjC class, alongside the GLLevelMeter, and modelled its implementation on the AQLevelMeter.mm class. 我在GLLevelMeter旁边添加了另一个视图SoundWaveView,一个ObjC类,并在AQLevelMeter.mm类上对其实现进行了建模。

After finding that the file should be named ".mm", the code compiles, but when executing, it crashes with EXC_BAD_ACCESS on the MeterTable object. 找到文件应命名为“ .mm”后,代码将编译,但是在执行时,它会在MeterTable对象上崩溃,并显示EXC_BAD_ACCESS。 Printing this object in the debugger gives the following: 在调试器中打印此对象将提供以下信息:

error: instance method 'setMeterTable:' has a different number of parameters in different translation units (0 vs. 1)
error: instance method 'setMeterTable:' has a different number of parameters in different translation units (0 vs. 1)
note: instance method 'setMeterTable:' also declared here
note: instance method 'setMeterTable:' also declared here
error: 2 errors parsing expression

Now I suspect that including the MeterTable.h in both AQLevelMeter.mm (Apple) and SoundWaveView.mm (mine) gives me the duplication, but how can I access MeterTable from my class without importing the .h?? 现在我怀疑在AQLevelMeter.mm(Apple)和SoundWaveView.mm(mine)中都包含MeterTable.h会使我重复,但是如何在不导入.h的情况下从类访问MeterTable?

Be sure to initialize all the nasty pointer stuff. 确保初始化所有讨厌的指针。 Or choose another language for less worries (sorry, I couldn't resist). 或选择其他语言以减少后顾之忧(对不起,我无法抗拒)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM