Jo Dillon wrote:
As I've said before on this list, I'm porting an Object Pascal application to MacOS using a GPC cross-compiler. I've got a sort of minimal runtime system on the Mac, which enables my application to run - however, it explodes on (as far as I can see) the first call to a virtual function. This may be because my implementation of GPC_New/_p_new just looks like this:
void * _p_new(int size) { return malloc(size); }
Whereas the proper one appears to do thinks like mark the object.
It is not _p_new() that does this job, but the compiler generates code to initialise the object after _p_new() has finished.
My question is, is it the case that I need to fix up the vtbl in _p_new, and if so where do I do it? Where does marking fit into it?
You can examine the assembler code whether the initialisation is done: There must be an assignment of the address of vmt_Fooobj (with `FooObj' being the name of your object type) to the first location in the new variable pointed to.
From the Pascal program you can examine this address with the
`TypeOf' function or assign a value to it with `SetType'.
Hope this helps,
Peter