[Ecls-list] How do I pass a pointer to a foreign int into a C function?
Warren Wilkinson
warrenwilkinson at gmail.com
Fri Jul 20 04:38:32 UTC 2012
I'm trying to call C functions that return arguments via int*. But I'm not
sure how to make an integer that I can use as a pointer in C, and still
read it back in ECL.
This code below doesn't work. It segfaults. Any help?
;;;;;
(clines "void test(int* a) {
*a = 5;
};")
(defun set-to-five ()
(with-foreign-object (item :int)
(c-inline (item) ((* :int)) :void "test(#0)" :one-liner t)
(format t "~%I GOT: ~a" (deref-pointer item :int))))
;;;;
Cheers,
Warren Wilkinson
1 403 383-7152
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20120719/c9d06909/attachment.html>
More information about the ecl-devel
mailing list