未知类型名称“类";您指的是 'Class'

Unknown type name #39;class#39;; did you mean #39;Class#39;?(未知类型名称“类;您指的是 Class 吗?)

本文介绍了未知类型名称“类";您指的是 'Class' 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 SpeakHere Apple Xcode 项目示例中实现 AQRecorder.h 类,但即使我将我的实现类重命名为 ext.*.mm#import "AQRecorder.h" 的行仍然得到错误 "Unknown type name 'class'; 你的意思是 'Class'?" 等等.在我看来,这意味着它不被识别为 C++ 类.

I'm trying to implement AQRecorder.h class from SpeakHere Apple Xcode project example, but even I rename my implementation class to ext. *.mm and put line with #import "AQRecorder.h" still getting error "Unknown type name 'class'; did you mean 'Class'?" and many others. Which according to me means that it is not recognized as C++ class.

任何帮助将不胜感激.

推荐答案

我刚刚遇到了这个问题.我有一个使用 AQRecorder.mm 中的 AQRecorder 类的视图控制器.

I've just had this exact problem. I had a view controller using the AQRecorder class from AQRecorder.mm.

当我在视图控制器中包含 AQRecorder.h 时,发生了这些错误.在我看来,这是因为我的直接 Objective-c 视图控制器(命名为 .m 文件)包含编译器抛出虚假错误的 C++ 头文件.

When I included AQRecorder.h in my view controller these errors occurred. It appeared to me because my straight objective-c view controller (named as a .m file) was including C++ header files the compiler was throwing spurious errors.

有两种解决方案.最快的方法是将包括 AQRecorder.h 在内的视图控制器类重命名为 .mm 文件,在我的情况下,将 UIRecorderViewController 从 .m 重命名为 .mm.

There are two solutions. The quickest is to rename the view controller class including AQRecorder.h to be a .mm file, in my case UIRecorderViewController from .m to .mm.

或者,移动以下包括:

#include "CAStreamBasicDescription.h"
#include "CAXException.h"

从 AQRecorder.h 到 AQRecorder.mm.这意味着直接的 C++ 样式的头文件将不再包含(通过引用)在您的普通 Obj-C 源代码中.

Out of AQRecorder.h into AQRecorder.mm. This means that straight C++ style header files will no longer be included (by reference) in your plain Obj-C source.

希望能有所帮助,并且有意义.

Hope that helps, and makes sense.

这篇关于未知类型名称“类";您指的是 'Class' 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:未知类型名称“类";您指的是 'Class'

基础教程推荐