[英]How do you create a pointer to a struct and type cast it?
can someone tell me where I'm going wrong here? 有人可以告诉我我要去哪里了吗? I'm trying to create a pointer to the struct aqData that is passed in to the function, and type type cast it to a struct type of AQPlayerState.
我正在尝试创建一个指向传递给函数的结构aqData的指针,并将其类型转换为AQPlayerState的结构类型。
I'm getting the errors - Use of undeclared identifier "AQPlayerState" and Expected expression 我遇到了错误-使用未声明的标识符“ AQPlayerState”和期望的表达式
@implementation AudioPlayer
#define kNumberBuffers 3
struct AQPlayerState {
AudioStreamBasicDescription mDataFormat;
AudioQueueRef mQueue;
AudioQueueBufferRef mBuffers[kNumberBuffers];
AudioFileID mAudioFile;
UInt32 bufferByteSize;
SInt64 mCurrentPacket;
UInt32 mNumPacketsToRead;
AudioStreamPacketDescription *mPacketDescs;
bool mIsRunning;
};
static void HandleOutputBuffer (
void *aqData,
AudioQueueRef inAQ,
AudioQueueBufferRef inBuffer
) {
struct AQPlayerState *pAqData = (AQPlayerState *) aqData;
Thanks in advance for any help 预先感谢您的任何帮助
I believe Objective-C
behaves as C
. 我相信
Objective-C
行为就像C
If it doesn't this might not apply to Objective-C
. 如果不是,这可能不适用于
Objective-C
。
structs in C are recognized by their "full name". C中的结构通过其“全名”识别。
Try 尝试
struct AQPlayerState *pAqData = (struct AQPlayerState *) aqData;
or , even better , don't cast at all. 或者 , 甚至更好 ,完全不要投放。 The C compiler knows how to convert from void*
to any other pointer to object C编译器知道如何从
void*
转换为任何其他指向对象的指针
struct AQPlayerState *pAqData = aqData;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.