native c header:
typedef HANDLE HCAMERA;
int Begin(HCAMERA* h);
int End(HCAMERA h);
HANDLE is defined:
typedef void *HANDLE;
native c source I want:
HCAMERA h;
int r = 0;
r = Begin(&h);
VERIFY(r);
r = End(h);
VERIFY(r);
I tried following code in sbcl 1.3.1 but not working.
(cffi:use-foreign-library "camera.dll")
(cffi:defcfun "Begin" :int
(handle :pointer))
(cffi:defcfun "End" :int
(handle :pointer))
(defparameter *camera* (cffi:foreign-alloc :pointer)) ; alloc handle
(cffi:with-foreign-object (handle :pointer)
(setf (cffi:mem-ref handle :pointer) *camera*) ; handle address
(Begin handle)
(End *camera*))
BTW: HOW TO GET THE ADDRESS OF THE FOREIGN OBJECT (camera)? AM I DOING IT RIGHT?