[racket] math/matrix <--> FFI/array
Another FFI question:
I want to interface a C function which has the following signature:
void iauA2tf(int ndp, double angle, char *sign, int ihmsf[4])
The "char *sign" parameter is a single char, not a string, output only, and
is giving me problems.
The C code uses this parameter simply:
*sign = (char) ( ( days >= 0.0 ) ? '+' : '-' );
If I use:
(define-sofa iauA2tf
(_fun (ndp : _int)
(angle : _double)
(sign : (_ptr o _int)) ; <====
(idmsf : (_ptr o (_array _int 4)))
-> _void
-> (values sign idmsf)))
It works (for a sufficiently pragmatic value of "works"), but the returned
sign is a number composed of one good byte and 3 garbage bytes.
I can get the correct result with (bitwise-and sign 255).
I tried:
(define-sofa iauA2tf
(_fun (ndp : _int)
(angle : _double)
(sign : (_ptr o _int8)) ; <====
(idmsf : (_ptr o (_array _int 4)))
-> _void
-> (values sign idmsf)))
But this crashes DrRacket.
I think I must be missing something simple. Please give me a hint.
Cheers
P.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130213/6ab11e65/attachment.html>