[racket] FFI question: problem passing a cstruct to a function for output

From: keydana at gmx.de (keydana at gmx.de)
Date: Wed Jul 20 16:02:11 EDT 2011

Hi all,

sorry I'm coming with an FFI question again ... I am stuck with an error passing a cstruct to a function for output, but unfortunately I'm not sure the problem is in my Racket code (I'd hope so, because in that case, I might hope for some help :-;)

I need to define a function

boolean OCI_GetStruct (OCI_Resultset * rs, void * row_struct, void * row_struct_ind)

 that takes 2 structs for output, and these have to be generic structs, not some define-cstruct defined concrete type; so I've tried passing the type in to the function and generating an output argument with (_ptr o <type>):

(def-ocilib getstruct OCI_GetStruct : (resultset_ptr structtype indtype) :: (resultset_ptr : _pointer) (struct_ptr : (_ptr o structtype)) (ind_ptr : (_ptr o indtype)) -> (result : _bool) -> (and result (values struct_ptr ind_ptr)))

Unfortunately, on execution I get an error

Msg: "OCI-21560: argument 3 is null, invalid, or out of range\n"

and my problem is, I do not even know what argument 3 is, as the OCILIB library I'm binding to itself uses the Oracle OCI code, and I'd have to find out exactly what function it was calling here...

I've tried another way too, passing the types as well as some "initialized" exemplar of the structure as a (_ptr io <type>):

(def-ocilib getstruct OCI_GetStruct : (resultset_ptr struct_ptr structtype ind_ptr indtype) :: (resultset_ptr : _pointer) (struct_ptr : (_ptr io structtype)) (ind_ptr : (_ptr io indtype)) -> (result : _bool) -> (and result (values struct_ptr ind_ptr)))

But I get the same error here...

One point that's not clear to me - the struct pointers are declared as void * in the function declaration - do I have to do something special for that?

Otherwise, I'd be very grateful for any hint, if my Racket code is wrong somehow - or otherwise, an idea how I might proceed here (some way to debug FFI calls)?

Many thanks in advance!


Posted on the users mailing list.