We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, while it isn't super common, it'd be nice to support passing and retrieving structs by value with FFI.
require "ffi" module Hello extend FFI::Library ffi_lib "./libhello.dylib" class World < ::FFI::Struct layout :a, :int, :b, :int end attach_function :get_struct, [], World.by_value attach_function :print_struct, [World.by_value], :void end Hello.print_struct(Hello.get_struct)
Code for shared library
// gcc -shared -o libhello.dylib hello.c #include <stdio.h> struct World { int a; int b; }; struct World get_struct(void) { struct World w = { .a = 1, .b = 2 }; return w; } void print_struct(struct World w) { printf("a = %d, b = %d\n", w.a, w.b); }
CRuby outputs:
a = 1, b = 2
TruffleRuby 24.2.0 currently errors with:
unknown simple type 'STRUCT_BY_VALUE' (Polyglot::ForeignException)
The text was updated successfully, but these errors were encountered:
Thank you for the report, we'll look into it.
Sorry, something went wrong.
Fiddle::Pointer#ref
This is blocked by struct-by-value support in Truffle NFI (internal issue: GR-13304). We'll have to wait until that is fixed.
Same as #2069, I'll close the older one as this issue is much clearer.
No branches or pull requests
Hi, while it isn't super common, it'd be nice to support passing and retrieving structs by value with FFI.
Code for shared library
CRuby outputs:
TruffleRuby 24.2.0 currently errors with:
The text was updated successfully, but these errors were encountered: