Did you read the UFFI chapter? https://ci.inria.fr/pharo-contribution/view/Books/job/PharoBookWorkInProgres... https://ci.inria.fr/pharo-contribution/view/Books/job/PharoBookWorkInProgres... I'm turning it into a booklet but I will not write it because I'm bad in FFI Now if you have corrections, suggestions, please do some pull requests https://github.com/SquareBracketAssociates/Booklet-uFFI Stef On Mon, May 22, 2017 at 10:42 PM, horrido <horrido.hobbies@gmail.com> wrote:
There is shockingly very little documentation on how to use uFFI. In particular, I have the following situation...
A shared C lib has the following function:
void get_machine(char *machine) { uname(&uname_s); strcpy(machine, uname_s.machine); }
It copies the content of a string value into the buffer passed to it (char *machine).
I want to call this function from Pharo, thus:
buffer := String new: 64. self ffiCall: #( void get_machine(String buffer) ).
The buffer never receives the string value (it just contains the 64 initiialized spaces).
Clearly, I'm misunderstanding the proper mechanism for doing this.
[There are other functions in the shared C lib that work fine, such as:
uint get_uptime() { sysinfo(&info); return info.uptime; }
Returning integers or floats is no problem. But passing arguments by reference seems to be verboten.]
-- View this message in context: http://forum.world.st/How-to- use-uFFI-with-String-tp4947890.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.