On 11/22/20 2:50 PM, Tim Meehan wrote:
I tried to boil this question down to the most simple thing that represented what I needed to understand. I have had luck getting C functions that expect arguments "by value," but "by reference" has been problematic. The failure mode is "Segmentation Fault," so I gather that I may not be using the right Guile call at all. The Guile user manual is usually quite excellent, but I seem to be missing something important. Thanks, ;;----------------------------------------------------------------------------;; ;; C source for "libstuff.so": ;; file stuff.c, compiled as: ;; gcc stuff.c -o libstuff.so -fPIC -shared #| void int_ptr_example1(int *a) { *a = 5; } |#
You'll need to make-bytevector a bytevector that holds sizeof(int) bytes. Then pass (bytevector->pointer <obj>) as the argument. (let ((obj (make-bytevector (sizeof int)))) (int-ptr-example (bytevector->pointer obj))) Now the 5 should be in the bytevector. You will need to extract it.