Now I&#39;ve not the code to try this, but I think it doesn&#39;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&#39;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 &lt;<a href="mailto:len-l@telus.net">len-l@telus.net</a>&gt;:</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 &lt;in_addr&gt;. It casts tmpinPtr to an in_addr<br> structure, not a pointer to in_addr (in_addr *). Try this:<br> <br><br> tmp = &lt;in_addr *&gt;tmpinPtr[0]<br> <br> <br> <br>Lenard<br> <br><br> <br>
 Daniele Pianu wrote:<br> &gt; Suppose this code<br> &gt;<br> &gt; # getIstance return a long, that is a pointer to a in_addr struct<br> &gt; cdef in_addr tmp<br> &gt; tmpinPtr = in_.getIstance()<br> &gt; tmp = &lt;in_addr&gt;tmpinPtr[0]<br>
 &gt;<br> &gt; # in this function gcc gives me an error<br> &gt; func( tmp )<br> &gt;<br> &gt; I take a pointer to a in_addr struct as a python long from the<br> &gt; getIstance method. Then, I need to call a C function and pass a<br>
 &gt; in_addr struct by value. With pyrex C the pyrex code compiles with no<br> &gt; problems. But gcc gives me the error in mail&#39;s subject.<br> &gt;<br> &gt; error: conversion to non-scalar type requested<br> &gt;<br>
 &gt; How can I pass the structure by value deferencing a python long and<br> &gt; casting it as the struct type I need?<br> &gt;<br> &gt; (I&#39;ve wrote similiar code for function where I pass the structure by<br> &gt; reference and there&#39;s no problems.)<br>
 &gt;<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>