Using <c-string> with FFI calls |
Home |
Introduction |
Tips and Techniques |
Projects |
Libraries |
Links |
|
The following relates to Functional Developer and Harlequin Dylan. The Dylan type If you have a pointer to a zero terminated string as a result of an FFI
call you can convert this to a Dylan let buffer = api-call-returning-pointer(); make(<c-string>, address: buffer.pointer-address); If the string you require from the API call is at a different location in the buffer than offset zero you can use pointer addition with something like the following: let buffer = api-call-returning-pointer(); make(<c-string>, address: \%+(buffer.pointer-address, 100)); If you want to copy a string from a Dylan let buffer = api-call-returning-pointer(); let dylan-string = "Hello World"; with-c-string(source = dylan-string) copy-bytes!(buffer, source, source.size + 1); end with-c-string; |
|
Copyright © 2000, Chris
Double. All Rights Reserved. |