[plt-scheme] cstruct and null pointer

From: Robert Nikander (nikander at nc.rr.com)
Date: Sat Oct 20 12:52:14 EDT 2007

Hi,

I have an FFI wrapper function that returns a pointer to a cstruct.   
The C function can return a null pointer, which causes an exception.   
Is there a way to get it to return #f instead?  Here are some more  
details...

The struct:

(define-cstruct _mysql-field ((name _string)
                               (org-name _string)
                               ...

The function:

(define/provide mysql-fetch-field
     (get-ffi-obj "mysql_fetch_field" libmysqlclient (_fun _mysql- 
result -> _mysql-field-pointer)))

The error when mysql_fetch_field returns NULL.

mysql-field->C: expected argument of type <non-null `mysql-field'  
pointer>; given #f


thanks,
Rob




Posted on the users mailing list.