-
-
Save NoCheroot/f084c0e38cb105d362991c9e3ca71ecd to your computer and use it in GitHub Desktop.
Chez Scheme FFI - Structs returned by value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (load-shared-object "./libsbv.so") | |
| (define-ftype color | |
| (struct | |
| [r float] | |
| [g float] | |
| [b float] | |
| [a float])) | |
| (define make-rgba | |
| (foreign-procedure "make_rgba" (float float float float) color)) | |
| ;; => invalid (non-base) foreign-procedure result ftype color |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* -*- compile-command: "gcc -c -Wall -Werror -fpic -o sbv.o struct_by_value.c; and gcc -shared -o libsbv.so sbv.o"; -*- */ | |
| struct color { | |
| float r; | |
| float g; | |
| float b; | |
| float a; | |
| }; | |
| struct color from_rgba(float r, float g, float b, float a) { | |
| struct color c; | |
| c.r = r; | |
| c.g = g; | |
| c.b = b; | |
| c.a = a; | |
| return c; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment