I am trying to translate some code from objective c to unmanaged c++
I have this operation
Buffer* ir =malloc( sizeof( Buffer ) );
error: expression must have pointer-to type?
the same error goes into this code
ir->buffer = malloc( bufferSize );
Could you please provide me correct use of malloc in this unmanaged c++?
malloc()returns avoid *which might be leading to this issue. You can cast the return:or, if you’re using C++, you should use
newinstead:(If you do, don’t forget to change the
free()todeletethough).