Re: error: conversion to non-scalar type requested

Lenard Lindstrom <[email protected]>
Newsgroups gmane.comp.python.pyrex
Message-ID <[email protected]>
The problems is with <in_addr>. It casts tmpinPtr to an in_addr 
structure, not a pointer to in_addr (in_addr *). Try this:

tmp = <in_addr *>tmpinPtr[0]


Lenard


Daniele Pianu wrote:
> Suppose this code
>
> # getIstance return a long, that is a pointer to a in_addr struct
> cdef in_addr tmp
> tmpinPtr = in_.getIstance()
> tmp = <in_addr>tmpinPtr[0]
>
> # in this function gcc gives me an error
> func( tmp )
>
> I take a pointer to a in_addr struct as a python long from the 
> getIstance method. Then, I need to call a C function and pass a 
> in_addr struct by value. With pyrex C the pyrex code compiles with no 
> problems. But gcc gives me the error in mail's subject.
>
> error: conversion to non-scalar type requested
>
> How can I pass the structure by value deferencing a python long and 
> casting it as the struct type I need?
>
> (I've wrote similiar code for function where I pass the structure by 
> reference and there's no problems.)
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.