I have a C++ class that I would like to use in my Objective-C project. Without #including any C++ headers, when I rename my Obj-C files from “.m” to “.mm”, and thus switch the compiler, the compiler produces a whole bunch of malloc errors:
double * pointValues = malloc(sizeof(double *)*numOfPts);
error: invalid conversion from 'void*' to 'double*'
Suddenly all lines with malloc become invalid.
Do I have to typecast “malloc” when using the Obj-C++ compiler, or is this a manifestation of some other issue?
In C++, there is no implicit conversion from
void*to other pointer types, so you have to explicitly cast.Not only with the objective-C++ compiler.