Hi,
Thanks for the example. Unfortunately, it doesn't work on Linux.
Thanks,
Gerry
From: Tomaž Turk
Sent: Sunday, November 28, 2021 11:39 AM
To: Any question about pharo is welcome
Subject: [Pharo-users] Re: uFFI provide buffer to C
Hi,
try with this:
FFITu
Hi,
try with this:
FFITutorial>>getHostNameInto: hostName ofLenght: length
^self ffiCall: #( int gethostname(char *hostName, int length) )
library: 'Ws2_32.dll'. "... on Windows"
From Playground, you can then do:
| name len |
len := 50.
name:= ByteArray new: len.
FFITutorial new getHos
Hi,
I'm just trying to work out how to do it. Please find my latest attempt below.
The docs aren't much help with this.
FFITutorial>>getHostName
| nameBuffer |
nameBuffer := ByteArray new: 256.
self ffiCall: #( int gethostname(ByteArray *nameBuffer, int 256) ) library:
'libc.so.6'.
^
hi,
it should be ByteArray.
if you explain more in detail your problem, I can try to help you better :)
Esteban
On Nov 28 2021, at 9:20 am, Gerry Weaver wrote:
>
> Hello All,
>
> Pharo newbie here. I'm playing around with uFFI and I'm having trouble
> figuring out how to provide a buffer to C.
Hello All,
Pharo newbie here. I'm playing around with uFFI and I'm having trouble figuring
out how to provide a buffer to C. It looks like maybe ByteArray would be the
type, but it's not working. Would some one be so kind as to show me an example
with the C function gethostname?
Thanks,
Gerry