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. 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?
The "marking" mentioned in rts/heap.pas refers to the Mark/Release statements. If you don't use them, you could omit this for now.
However, you should probalby check if the return value of malloc() is NULL, and cause a runtime error if so.
Actually, can't you just take most of the code in rts/heap.pas (and the little bits in rts/rt0.c? AFAICS, they're essentially based on malloc()/free(), and therefore might work under MacOS as is.
But all of this might not have anything to do with the problem you're experiencing...
Frank
-- Frank Heckenbach, frank@fjf.gnu.de, http://fjf.gnu.de/ GPC To-Do list, latest features, fixed bugs: http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html