<div dir="ltr">One way would be to return a special C "int-or-boolean" structure and then access it via special accessors. E.g. (let* ((r (your-c-call))) (if (struct=false? r) #f (struct-int r))) ?<div><br>Marc, any better ideas?</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-01-06 19:41 GMT+08:00 Alex Silva <span dir="ltr"><<a href="mailto:asandroq@gmail.com" target="_blank">asandroq@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello list,<br>
<br>
I am currently writing some FFI code that interfaces with libtiff to<br>
read tags from TIFF image files. The values of these tags have different<br>
C types and using the right type is needed to avoid memory corruption.<br>
<br>
For reading tags with uint16 values the code is straightforward:<br>
<br>
```<br>
static ___SCMOBJ uint16_tag(TIFF *tiff, ttag_t tag)<br>
{<br>
  uint16 val;<br>
  int ret = TIFFGetField(tiff, tag, &val);<br>
<br>
  return ret == 1 ? ___FIX(val) : ___FAL;<br>
}<br>
```<br>
<br>
But, since fixnums have less than 32 bits I cannot use the same code. It<br>
seems the solution would be something similar to:<br>
<br>
```<br>
static ___SCMOBJ uint32_tag(TIFF *tiff, ttag_t tag)<br>
{<br>
  uint32 val;<br>
<br>
  if(TIFFGetField(tiff, tag, &val) == 1)<br>
  {<br>
    ___SCMOBJ ret;<br>
    ___U32_to_SCMOBJ(___ps, val, &ret, ___RETURN_POS);  <---- ERROR<br>
    return ret;<br>
  }<br>
  else<br>
  {<br>
    return ___FAL;<br>
  }<br>
}<br>
<br>
```<br>
<br>
except that I don't know how to get hold of the processor state. Can<br>
anybody shed a light here?<br>
<br>
Thanks,<br>
-alex<br>
<a href="http://unendli.ch/" rel="noreferrer" target="_blank">http://unendli.ch/</a><br>
_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" rel="noreferrer" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
</blockquote></div><br></div>