Jerome Abela wrote:
>I'm trying to use an external C function which returns a pointer
>to a structure.
>I have two needs:
>1. I need to pass the pointer to other functions.
>2. I need to inspect some of the fields of the structure.
>Here are the solutions I was able to implement.
>1. Using c-pointer.
>2. Using (c-ptr mystruct).
I've just implemented the long-awaited (c-pointer mystruct) c-type. It's in CVS.
I tink it's exactly what you need.
It's not documented in CVS doc/ yet, because I can't remember how I managed to get nsgmls to work to check impnotes.xml. I won't touch an XML file without a checker to assist me. So documentation is left to somebody else for now.
Example: In Linux glibc, errno is not an extern variable anymore, but a
#define errno *(__errno_location)
so that each thread gets its own value.
(def-call-out errno-location (:name "__errno_location")
(:arguments) (:return-type (c-pointer int)))
(define-symbol-macro errno (foreign-value (__errno_location))); setf-able
Open issue: (c-pointer nil) is really is strange animal. What is it? Will it be used inadvertently (e.g. by UFFI transformations) in strange ways?
If you need void*, then you use c-pointer, just as before. Not (c-pointer nil).