Atronix Rebol 3 FFI looks pretty good in wrapping external functions, but I cannot find any references about wrapping external variables using it.
For example, Curses/NCurses library have the external variable stdscr defined in C as
extern WINDOW *stdscr;
I want to use it in my Rebol code. Ideally I want to use it as a common Rebol variable, but a read-only access (as a result of a function call, for example) would be great too.
Is it possible with Rebol 3 FFI?
I know that this practice might be considered harmful, but sometimes external libraries are written this way.
You can do this with the commit. Prebuild binaries can be downloaded from here (only in development releases)
Here is the example code:
rebol []
ncurses: make library! %libncursesw.so
stdscr: make struct! compose/deep [
[
extern: [(ncurses) "stdscr"]
]
ptr [pointer]
]
print ["stdscr:" stdscr/ptr]
close ncurses
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With