[Pyrex] void *

Andreas Kostyrka andreas at mtg.co.at
Sun Oct 19 17:56:06 CEST 2003


On Fri, Oct 17, 2003 at 09:13:59PM -0700, Bryan Weingarten wrote:
> i'm wrapping a c api that is similar to this:
> 
> void * foo_init();
> void    foo_close(void *ctx);
Well, try this:
cdef extern from "foo.h":
  void *foo_init()
  void foo_close(void *)

cdef class Foo:
  cdef void *ctx
  def __init__(self):
    self.ctx = foo_init()
  def __del__(self):
    foo_close(self.ctx)

Andreas
> 
> i've successfully wrapped and tested it but i'm getting compiler 
> warnings that i would like to get rid of.
> 
> i was unable to get pyrex to work the void * so i told pyrex that the 
> function prototypes are int's:
> 
> cdef extern from "foo.h":
>    int    foo_init()
>    void foo_close(int ctx)
> 
> class Foo:
>    def __init__(self):           
>        self.ctx = mpgedit_play_init()        
>        
>    def __del__(self):
>        foo_close(self.ctx)
>       
> 
> but this causes warnings like this:
> 
> mpgedit.c(73) : warning C4047: 'function' : 'long ' differs in levels of 
> indirection from 'void *'
> mpgedit.c(73) : warning C4024: 'PyInt_FromLong' : different types for 
> formal and actual parameter 1
> mpgedit.c(105) : warning C4022: foo_close' : pointer mismatch for actual 
> parameter 1
> 
> is there a better way to hand the void * instead of pretending it's an int?
> 
> thanks for any help,
> 
> bryan
> 
> 
> 
> 
> _______________________________________________
> Pyrex mailing list
> Pyrex at lists.copyleft.no
> http://lists.copyleft.no/mailman/listinfo/pyrex




More information about the Pyrex mailing list