Yeah, that example wasn't working for me either. If you put "(use easyffi)" at the top of the file though, it should work. Note that easyffi is deprecated, use
bind instead:
(use bind)
(bind* "double modf(double x, ___out double *iptr);")
(let-values ([(frac int) (modf 33.44)])
(print frac " " int))
I'm afraid I don't understand what Kon means either...
If 64-bit integers are all you need, perhaps you can use the foreign type unsigned-integer64? I'm guessing the C compiler will handle that even if you're on a 32bit system. I'm not sure how Chicken will handle integer64's if you're on a 32bit system though.
If you want to continue using your multiword version, you could look into the u32vector foreign type. It will give you a nice array on the C-side, and a nice vector on the Chicken side:
(use srfi-4)
(define double->uint64
(foreign-lambda* void ((double d) (u32vector _o))
"
uint32_t* ptr = (uint32_t*)&d;
_o[0] = ptr[0];
_o[1] = ptr[1];
"))
(define (double->byte-blob value)
(let ((out (make-u32vector 2)))
(double->uint64 value out)
out))
(print (double->byte-blob 1.3) "\n"
(double->byte-blob 0) "\n"
(double->byte-blob 1) "\n"
(double->byte-blob 100))
I don't know if this is a good approach, though. Maybe someone knows how uint64_t foreign-types are handled on 32bit systems?
K.