[plt-scheme] FFI - Implicit binding of _int to the correct _int32 or _int64
At Wed, 26 Sep 2007 18:44:24 -0400, Ray Racine wrote:
> In the below code I've changed what were _int to _int64 types. If leave
> them as _int, I segfault on the 64 bit machine.
>
> (define HMAC-SHA1/raw
> (get-ffi-obj 'HMAC openssl-crypto
> (_fun [EVP_MD : _fpointer = (EVP_SHA1)]
> [key : _bytes]
> [key_len : _int64 = (bytes-length key)]
> [data : _bytes]
> [data_len : _int64 = (bytes-length data)]
> [md : _int64 = 0]
> [md_len : _int64 = 0]
> ->
> _pointer)))
>
> Does / should the FFI automatically bind _int to _int32 or _int64
> i.e. the "right" size?
I think `int' normally means 32 bits on both 32-bt and 64-bit machines.
So, if a C prototype says `int', I'd expect `_int' to be the right FFI
choice. Unlike `int', the `long' type's size normally varies.
After looking at "hmac.h" on my machine, I wonder whether the problem
is that the md_len argument is supposed to be a pointer to an integer,
not an integer?
Matthew