I finally distilled it to this code -
Test C code (test.c)
typedef float testing[2];
void tester (testing* in, float a1, float a2, float a3, float a4)
{
in[0][0] = a1;
in[0][1] = a2;
in[1][0] = a3;
in[1][1] = a4;
}
What i want is to create a testing* in lisp, fill it using the function tester, and print the results back in lisp by accessing the testing* pointer. The code!:
Code: Select all
(defcfun "tester" :void (pt :pointer)
(a1 :float) (a2 :float) (a3 :float) (a4 :float))
(cffi:with-foreign-object (a :pointer 2)
(tester a 1.0 2.0 44.0 2.00)
(print (mem-aref (mem-aref a :pointer) :float))
)
Code: Select all
(with-foreign-object (a :pointer 2)
(setf (mem-aref a :pointer) (cffi:foreign-alloc :float :initial-contents '(0.0 0.0)))
(setf (mem-aref a :pointer) (cffi:foreign-alloc :float :initial-contents '(0.0 1.0)))
(tester a 1.0 2.0 44.0 2.00)
(print (mem-aref (mem-aref a :pointer) :float))
)
Error: Attempt to take the car of #<Function MEMREF-INT> which is not listp.
[condition type: TYPE-ERROR]
I have NO clue whats wrong

Please Help!!!!
