<div>Another FFI question:</div><div><br></div><div>I want to interface a C function which has the following signature:</div><div><br></div><div><div>void iauA2tf(int ndp, double angle, char *sign, int ihmsf[4])</div></div>
<div><br></div><div>The &quot;char *sign&quot; parameter is a single char, not a string, output only, and is giving me problems.</div><div><br></div><div>The C code uses this parameter simply:</div><div><br></div><div><div>
   *sign = (char) ( ( days &gt;= 0.0 ) ? &#39;+&#39; : &#39;-&#39; );</div></div><div><br></div><div>If I use:</div><div><br></div><div><div>(define-sofa iauA2tf</div><div>  (_fun (ndp : _int)</div><div>        (angle : _double)</div>
<div>        (sign : (_ptr o _int))  ; &lt;====</div><div>        (idmsf : (_ptr o (_array _int 4)))</div><div>        -&gt; _void</div><div>        -&gt; (values sign idmsf)))</div></div><div><br></div><div>It works (for a sufficiently pragmatic value of &quot;works&quot;), but  the returned sign is a number composed of one good byte and 3 garbage bytes.</div>
<div>I can get the correct result with (bitwise-and sign 255).</div><div><br></div><div>I tried:</div><div><br></div><div><div><div>(define-sofa iauA2tf</div><div>  (_fun (ndp : _int)</div><div>        (angle : _double)</div>
<div>        (sign : (_ptr o _int8))  ; &lt;====</div><div>        (idmsf : (_ptr o (_array _int 4)))</div><div>        -&gt; _void</div><div>        -&gt; (values sign idmsf)))</div></div></div><div><br></div><div>But this crashes DrRacket.</div>
<div><br></div><div>I think I must be missing something simple.  Please give me a hint.</div><div><br></div><div>Cheers</div><div>P.</div><div><br></div>