Perhaps using "long" to represent the string could work

 or using long* with the following hard coded manner to pass the string..

               bytes := 'adsadsasdd' asByteArray.
ea := ( ExternalAddress  allocate: bytes size)  .
  1 to: bytes size do: [ :e |
 ( ea byteAt: e put: ( bytes at: e ) ].
out := ea asInteger.

will try it out and let you know further.. but I guess it should work...
null terminate if that is desired..


On Sun, Apr 29, 2012 at 1:26 AM, <[email protected]> wrote:

> Hi,
>
> I'm trying to pass a smalltalk string to a FFI wrapper method I've
> written, the C function uses a macro "type" for the argument, but as far as
> I can see is basically a char* type. I've tried using char* as the argument
> type and it fails values to pass the string argument.
>
> If I change the argument type to a void* it works sort of partially, it
> passes additional memory values if I pass more than one argument to a
> version of the function with multiple arguments. As I understand it FFI
> should handle strings and coerce them to null terminated char* values when
> char* is used as the argument type. Is there something I'm missing, not
> understanding (very possible).
>
> I had similar problems when passing integer values but fixed that by using
> WordArray for the smalltalk type. Is there a similar fix for string
> objects, or someway other way of null terminating the string ?
>
> Thanks
>

Reply via email to