xcode 未知类型名称“类”;您指的是 'Class' 吗?奥里奥触控
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9415886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unknown type name 'class'; did you mean 'Class'? AurioTouch
提问by LordPingvin
I'm trying to move code from the AurioTouch project to my project. But I have many errors:
我正在尝试将代码从 AurioTouch 项目移动到我的项目。但我有很多错误:
Unknown type name 'class'; did you mean 'Class'?
For example, in file FFTBufferManager.h:
例如,在文件 FFTBufferManager.h 中:
#include <AudioToolbox/AudioToolbox.h>
#include <libkern/OSAtomic.h>
#include "SpectrumAnalysis.h"
class FFTBufferManager
{
public:
FFTBufferManager(UInt32 inNumberFrames);
~FFTBufferManager();
I tried to change the compiler to LLVM GCC 4.2, but it gives a lot of other errors:
我试图将编译器更改为 LLVM GCC 4.2,但它给出了很多其他错误:
Expected '=', ',', ';', 'asm' or '__attribute__' before 'FFTBufferManager'
What am I doing wrong?
我究竟做错了什么?
回答by Joe
To mix C++ and Objective-C you need to use the .mm extension. If, however, your class is only C++ (and only includes C/C++ headers) then you can use the normal .cpp
extension.
要混合使用 C++ 和 Objective-C,您需要使用.mm 扩展名。但是,如果您的类只是 C++(并且只包含 C/C++ 头文件),那么您可以使用普通.cpp
扩展。
.mm
A source file with this extension can contain C++ code in addition to Objective-C and C code. This extension should be used only if you actually refer to C++ classes or features from your Objective-C code.
.mm
除了Objective-C 和C 代码之外,具有此扩展名的源文件还可以包含C++ 代码。仅当您从 Objective-C 代码中实际引用 C++ 类或功能时,才应使用此扩展。