[cffi-devel] Cannot call function with char** arg
Nikolai Nespor
nikolai.nespor at utanet.at
Fri Apr 21 17:54:47 UTC 2006
In reply to James Bielman:
I just managed to do a quick test, I'll have some more time tomorrow.
> Does something like the following work for you? It'd be nice to
> massage this into something worth including in src/strings.lisp...
[snip]
> ;;; Bind ARGC and ARGV to the count and pointer of a C-style string
> ;;; vector, taking strings from SEQUENCE. The vector is automatically
> ;;; freed upon exit of BODY.
> (defmacro with-foreign-string-vector ((argc argv sequence) &body body)
> (cffi-utils:once-only (sequence)
> `(let* ((,argc (length ,sequence))
> (,argv (foreign-string-vector ,sequence ,argc)))
> (unwind-protect
> (progn , at body)
> (foreign-string-vector-free ,argv ,argc)))))
If I call it like this (which I hope is right, since I'm just learing lisp)
rrd> (with-foreign-string-vector (argc argv '("create" "test.rrd" "--step=300" "DS:a:GAUGE:600:U:U" "DS:b:GAUGE:600:U:U" "RRA:AVERAGE:0.5:1:300"))
(rrd-create argc argv))
I get this error:
arithmetic error FLOATING-POINT-INVALID-OPERATION signalled
[Condition of type FLOATING-POINT-INVALID-OPERATION]
Restarts:
0: [ABORT-REQUEST] Abort handling SLIME request.
1: [ABORT] Exit debugger, returning to top level.
Backtrace:
0: (SB-VM:SIGFPE-HANDLER #<unavailable argument> #.(SB-SYS:INT-SAP #X283822C0) #.(SB-SYS:INT-SAP #X28382000))
1: (SB-SYS:INVOKE-INTERRUPTION #<CLOSURE (LAMBDA NIL) {49C44A75}>)
2: ("foreign function: call_into_lisp")
3: ("foreign function: funcall3")
4: ("foreign function: interrupt_handle_now")
5: ("foreign function: interrupt_handle_now_handler")
6: ("bogus stack frame")
7: ("foreign function: rrd_create_r")
8: ("foreign function: rrd_create")
9: (RRD-CREATE 6 #.(SB-SYS:INT-SAP #X082661C0))
10: (NIL)
11: (SB-INT:EVAL-IN-LEXENV (WITH-FOREIGN-STRING-VECTOR (ARGC ARGV (QUOTE #)) (RRD-CREATE ARGC ARGV)) #<NULL-LEXENV>)
--more--
which is further than I ever got before. It would usually bail out before
calling into rrd_create_r - the function where the real work is done.
I'm using SBCL 0.9.9 with SLIME CVS from a few weeks ago on x86 FreeBSD. CFFI
is 0.9.0.
I'll dig deeper tomorrow, thanks for the quick answer
Nikolai
--
Ich verwalte sie. Ich zähle sie und zähle sie wieder.
Das ist nicht leicht. Aber ich bin ein ernsthafter Mann.
\\
---> Antoine de Saint-Exupery, "Der kleine Prinz"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20060421/54eb536e/attachment.sig>
More information about the cffi-devel
mailing list