[Ecls-list] C-STRINGs and lisp strings

Goffioul Michael goffioul at imec.be
Tue Jun 28 07:09:04 UTC 2005


> >I looked at the CVS notification mail and I have the impression that
> >the problem still exists in case like:
> >
> >(ffi:def-function ("strlen" f1) ((arg :cstring)) :returning 
> :unsigned-int)
> >(f1 (format nil "~{~A~^, ~}" '(a b c d)))
> >
> >The FORMAT call returns a non-simple string, and the 
> generated code for F1
> >will probably only call ecl_string_pointer_safe() on it.
> >
> Sure. I have fixed also ecl_string_pointer_safe(), which 
> should probably 
> be renamed to ecl_string_to_cstring().

I'm not sure about your last change on ffi.d. If I'm right, the C function
will be passed a copy of the char array representing the LISP string (at
least for non-simple string). This means that you can't pass a buffer that
is intended to be filled by the C function, but this is a pattern that is
widely used in C API's (or maybe then that C function should be declared
with (* :char) instead of :cstring argument).

Michael.


More information about the ecl-devel mailing list