python ctype question about "access violation reading location 0x5a5a5a5a"
Chris Mellon
arkanes at gmail.com
Tue Mar 28 21:34:03 EST 2006
On 3/28/06, Yanping Zhang <zhan0645 at yahoo.com> wrote:
> Hi All,
>
> I need to use this C routine in python and there is a void pointer parameter in it:
> (this routine was written by someone else):
>
> myfunc(int a, (void *)userdata, bool b)
>
> I saw someone in his C++ wrapper used this routine in this way:
> myfunc(a, (void *)0x5a5a5a5a, b)
>
> In my python wrapper, I tried to call it as the following and both failed:
> 1. myfunc(c_int(a), 0x5a5a5a5a, c_int(b))
> got error "access voilation reading from 0x5a5a5a5a"
> 2.
> data = 0x5a5a5a5a
> mydata = c_void_p(data)
> myfunc(c_int(a), mydata, c_int(b))
> same error as in 1
>
> Can anyone know how to fix it? Thanks!
>
You are re-creating the C code correctly, the problem is that C code
you're working from is wrong (and whoever wrote it should be beaten).
Passing a constant like that as a pointer (that myfunc presumably does
something with) is something that just can't work.
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list