I am in the process of porting the file rc_actor.c to rc_actor.cpp for the game Rise of the Triad (see my progress page). I had forgotten how flexible (or loose) C is compared to C++.
The difference in type checking between C and C++ can be maddening when porting simple function pointers:
In C, you can declare a function pointer as:
void (think *) (void *);
and
void gettarget(objtype *);
You can then assign:
think = gettarget;
In C++, you must declare gettarget as
void gettarget(void * tob)
{
// Must assign ob to tob
// tob is the void*, cast to objtype*
objtype * ob = tob;
....
}
If you do not, then you will see the following error:
error C2440: '=' : cannot convert from 'void (__cdecl *)(void *)' to 'void (__cdecl *)(objtype *)'
Converting the function calls, and handling any code changes neccessary for casting void* to objtype* is very tedious. I'm down to about 75 errors in my work with rt_actor.cpp. I certainly hope it all works after I complete the port.