Now I've not the code to try this, but I think it doesn't solve the problem. func function needs a struct in_addr, not a pointer to struct in_addr, so the cast is correct. Maybe the problem is in the generated C code. I'll post the original pyrex (and C generated) code that originate this error very soon to give you more details.<br>
<br><div><span class="gmail_quote">2008/4/10, Lenard Lindstrom <<a href="mailto:len-l@telus.net">len-l@telus.net</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The problems is with <in_addr>. It casts tmpinPtr to an in_addr<br> structure, not a pointer to in_addr (in_addr *). Try this:<br> <br><br> tmp = <in_addr *>tmpinPtr[0]<br> <br> <br> <br>Lenard<br> <br><br> <br>
Daniele Pianu wrote:<br> > Suppose this code<br> ><br> > # getIstance return a long, that is a pointer to a in_addr struct<br> > cdef in_addr tmp<br> > tmpinPtr = in_.getIstance()<br> > tmp = <in_addr>tmpinPtr[0]<br>
><br> > # in this function gcc gives me an error<br> > func( tmp )<br> ><br> > I take a pointer to a in_addr struct as a python long from the<br> > getIstance method. Then, I need to call a C function and pass a<br>
> in_addr struct by value. With pyrex C the pyrex code compiles with no<br> > problems. But gcc gives me the error in mail's subject.<br> ><br> > error: conversion to non-scalar type requested<br> ><br>
> How can I pass the structure by value deferencing a python long and<br> > casting it as the struct type I need?<br> ><br> > (I've wrote similiar code for function where I pass the structure by<br> > reference and there's no problems.)<br>
><br> <br> <br> <br>_______________________________________________<br> Pyrex mailing list<br> <a href="mailto:Pyrex@lists.copyleft.no">Pyrex@lists.copyleft.no</a><br> <a href="http://lists.copyleft.no/mailman/listinfo/pyrex">http://lists.copyleft.no/mailman/listinfo/pyrex</a><br>
</blockquote></div><br>