#Using C from C++
The reason changing the extension from .c to .cp made it work is the functions
are now C++ functions, complete with mangled names. That's where you were
running into trouble before. To inhibit the name mangling, put 'extern "C"' in
front of the prototype, like so:
extern "C" void *myFunc (int arg1, float arg2);
// or
extern "C"
{
void *myFunc (int arg1, float arg2);
int *myFunc1 (int arg1, float arg2); // also a C function
}
Now, for the pointer conversion. Let me see if I understand what you're
saying. You want to do something like this in C++?
void *vPtr;
char *cPtr;
// assume pointers are initialized & what-not
cPtr = vPtr; // or equivalent in a function call
In other words, you want to put the contents of a void pointer into a char
pointer? C++ lets you assign any pointer type to variable of type void *, but
NOT the other way around; C++ considers such things "unsafe." Typecasting,
however, works, as in
(char *)vptr = cPtr;
Joe