Closed aerphanas closed 3 days ago
scryer-prolog version: 0.9.4 OS: Linux Debian 12 bookworm
I am trying to use raylib with scryer-prolog. When I use DrawRectangleRect, it panicked. Then I did some experiments and wrote a simple C code to test it.
typedef struct Rectangle { float x; // Rectangle top-left corner position x float y; // Rectangle top-left corner position y float width; // Rectangle width float height; // Rectangle height } Rectangle; Rectangle test_rect(void) { return (Rectangle){ 0.0f, 0.0f, 50.0f, 50.0f }; } float test_float(void) { return 3.0f; }
$ cc ret.c -o ret.so -shared $ scryer-prolog ?- use_module(library(ffi)). true. ?- foreign_struct(rectangle, [f32, f32, f32, f32]). true. ?- use_foreign_module("./ret.so", ['test_float'([], f32), 'test_rect'([], rectangle)]). true. ?- ffi:'test_float'(X). X = 3.0. ?- ffi:'test_rect'(X). thread 'main' panicked at src/ffi.rs:452:25: internal error: entered unreachable code note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
True, the read_struct function is missing implementation for floats and doubles. I'll prepare a fix
read_struct
i tested it today, now it works, thanks
scryer-prolog version: 0.9.4 OS: Linux Debian 12 bookworm
I am trying to use raylib with scryer-prolog. When I use DrawRectangleRect, it panicked. Then I did some experiments and wrote a simple C code to test it.