0

I'm working on a iOS project which as several c++ class. But as it seems compiling them are not straightforwards. I tired different methods but all the time give some errors.

1) First I renamed .m;class to .mm and try to compile and it gives a error. in this line

SInt16 *editBuffer = audioBufferList->mBuffers[0].mDat;

Error - "Cannot initialize a variable of type 'SInt16 *' (aka 'short *') with an lvalue of type 'void *'"

2) When setting Other Linker Flags to -ObjC++ it gives these two errors. Unknown type name 'class'; did you mean 'Class'?

'deque' file not found - for #include<deque>

Anyone has any idea , what's wrong here. Thanks in advance.

3
  • Linker flags will not effect the compiler. Have you tried setting the compiler option for Objective-C++? Commented Nov 21, 2012 at 19:06
  • Yes, it gives the error number 1. Commented Nov 21, 2012 at 19:14
  • First error is due to a noncompliant type. If my assumption about this involving CoreAudio is right, audioBufferList->mBuffers[0].mDat is the buffer address. SInt16* and void* types pointing to the same buffer won't behave the same where pointer math is concerned. You need to either cast the void* to SInt16*, or retype editBuffer to a compliant type such as void* or char*. Commented Nov 21, 2012 at 19:28

1 Answer 1

1

The first error is expected. C++ is finicky about void pointers.

SInt16 *editBuffer = (SInt16 *)(audioBufferList->mBuffers[0].mDat);

or

SInt16 *editBuffer = static_cast<SInt16 *>(audioBufferList->mBuffers[0].mDat);

See Casting To and From void*.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.