[cffi-devel] [johan at riise-data.no: Re: using defcenum keywords in function call]
Johan Ur Riise
johan at riise-data.no
Sat Sep 26 18:11:25 UTC 2009
----- Forwarded message from Johan Ur Riise <johan at riise-data.no> -----
Subject: Re: [cffi-devel] using defcenum keywords in function call
Date: Sat, 26 Sep 2009 07:09:49 +0200
From: Johan Ur Riise <johan at riise-data.no>
To: Stelian Ionescu <sionescu at cddr.org>
On Sat, Sep 26, 2009 at 05:19:15AM +0200, Stelian Ionescu wrote:
>
> DEFCENUM doesn't define constants(as in C), but a type which gets
> translated to integers if you specify it as argument type. In other
> words, this is correct:
>
> (defcfun ("socket" win-socket) socket
> "Creates a socket with the overlapped mode as default"
> (af af)
> (type sock-type)
> (protocol pf))
>
Thanks, that worked, and I can see now that the curl example shows how to do it.
For the record, this definition has a better chance of actually returning a socket:
(defcenum af
:af-unspec
:af-unix
:af-inet)
(defcenum sock-type
(:sock-stream 1)
:sock-dgram
:sock-raw)
(defcenum proto
(:tcp 6)
(:udp 17))
(defun make-socket ()
(foreign-funcall "socket"
af :af-inet
sock-type :sock-stream
proto :tcp
socket))
----- End forwarded message -----
More information about the cffi-devel
mailing list