[gambit-list] How to get the correct Tag for a call to POINTER_to_SCMOBJ (FFI)

Till tritill at gmail.com
Tue Jul 19 12:48:57 EDT 2011

> 1) Have you compiled Gambit with the --enable-cplusplus option?

As far as i remember i only changed the compiler to g++. I updated from 4.6.0 to 4.6.1 and recompiled with --enable-cplusplus and it does not segfault anymore.

> 2) Are you using multiple inheritance for your Node type?  The casts may cause problems in this case.

No inheritance at all.

> 3) You say your code segfaults when not using the #f to omit typechecks.  This is strange.  You should get an error message, not a segfault.

It works fine now, i dont even have to pass #f anymore. But the pointer still shows up as foreign of course. 
#<foreign #2 0x100855ad0>

> 4) The code:
>> (define get-childnodes
>>   (c-lambda (Node*) scheme-object "LIST_to_SCMOBJ<Node*>(___arg1->childs(), &___result);")))
> is strange.  The function LIST_to_SCMOBJ returns an error code, and a result in the second parameter.  You are ignoring the error code, which is not a good idea.  It is best to implement conversion operations on your type.  For example:

Ah, yeah - i should check and handle the error. I will write the conversion operations and fiddle with it. But my original question remains, when i call POINTER_to_SCMOBJ, how can i pass the Node* type tag? like in:

___SCMOBJ NodeSTAR_to_SCMOBJ(Node *src, ___SCMOBJ *dst, int arg_num) 
	return ___POINTER_to_SCMOBJ(src, ?????, NULL, dst, arg_num);

___FAL works there, but gives me pointers of type foreign, which now work after after my self build problem is gone. I can leave it at that, i just thought there might be a way to tell POINTER_to_SCMOBJ the right type, if it makes any sense at all.

Thanks for looking into it!

More information about the Gambit-list mailing list