Are you sure that, now that each constant has a fixed integer value, the compiler is allowed to represent this internally as anything else than an int?<br>Check it out. If not, you know it's an int, so you could just typecast<br>

<br><div class="gmail_quote">2012/2/5 Álvaro Castro-Castilla <span dir="ltr"><<a href="mailto:alvaro.castro.castilla@gmail.com">alvaro.castro.castilla@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

This is the definition  in C:<div><br></div><div><div>typedef enum _cairo_format {</div><div>    CAIRO_FORMAT_INVALID   = -1,</div><div>    CAIRO_FORMAT_ARGB32    = 0,</div><div>    CAIRO_FORMAT_RGB24     = 1,</div><div>
    CAIRO_FORMAT_A8        = 2,</div>


<div>    CAIRO_FORMAT_A1        = 3,</div><div>    CAIRO_FORMAT_RGB16_565 = 4</div><div>} cairo_format_t;</div></div><div><br><br>AFAIK, bindings in Gambit usually deal with this as an integer, but with C++ enabled, conversion is needed.</div>

<div><div></div><div class="h5">

<div><br></div><div><br><br><br><div class="gmail_quote">2012/2/5 Mikael <span dir="ltr"><<a href="mailto:mikael.rcv@gmail.com" target="_blank">mikael.rcv@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<br><br><div class="gmail_quote"><div>2012/2/5 Álvaro Castro-Castilla <span dir="ltr"><<a href="mailto:alvaro.castro.castilla@gmail.com" target="_blank">alvaro.castro.castilla@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div>Hi!</div><div><br></div><div>I open a new thread, because this is a deeper issue than the C++ enums conversion problem.</div><div><br></div><div>When I declare this:</div><div><br></div>(define CAIRO_FORMAT_RGB24 ((c-lambda () cairo-format-t "___result = CAIRO_FORMAT_RGB24;")))<div>







<br></div><div>or:</div><div>(define CAIRO_FORMAT_RGB24 (c-lambda () cairo-format-t "___result = CAIRO_FORMAT_RGB24;"))</div><div>and then call</div><div>(CAIRO_FORMAT_RGB24)</div><div><br></div><div>my program segfaults. It seems that just executing that c-lambda, returning an enum, fails. The enum is defined as:  (c-define-type cairo-format-t "cairo_format_t")</div>





</blockquote></div><div><br>Ouch - your declaration makes Gambit identify, I think, cairo_format_t as a C structure, and tries to copy its contents fully. Hmm. If this is not how it really is, do (c-define-type cairo-format-t integer) or sth?<br>





</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>

<div><br></div><div>I don't understand why this segfaults: 1) I'm declaring the type 2) I'm returning the proper type. What's the problem?</div><div><br></div><div><br></div><div>Best regards,</div><div><br>







</div><font color="#888888"><div>Álvaro</div>
</font><br></div>_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca" target="_blank">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
<br></blockquote></div><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br>