[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 05:21:23 UTC 2012


Yes it does. Here is the updated, and now working code.  Thank you so much!

(clines "void test(int* a) {
   *a = 5;
};")

(defun set-to-five ()
  (with-foreign-object (item :int)
    (c-inline (item) (:pointer-void) :void "test(#0)" :one-liner t)  ;;
CHANGE (* :int) to :pointer-void
    (format t "~%I GOT: ~a" (deref-pointer item :int))))

Cheers,
Warren Wilkinson


On Thu, Jul 19, 2012 at 11:00 PM, Matthew Mondor
<mm_lists at pulsar-zone.net>wrote:

> On Thu, 19 Jul 2012 22:38:32 -0600
> Warren Wilkinson <warrenwilkinson at gmail.com> wrote:
>
> > * :int
>
> It's been a while since I used the FFI, but does :pointer
> or :pointer-void work here instead of * :int ?
> --
> Matt
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Ecls-list mailing list
> Ecls-list at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ecls-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20120719/a9910943/attachment.html>


More information about the ecl-devel mailing list