ctypes: reference of a struct member?

2009-05-01 Thread ma
If I have this struct in C: struct spam { int ham; char foo; }; if I have this declaration: struct spam s_; If I wanted to pass a reference to a function of s_'s foo character, I can do something like this: somefunc(s_.foo) How do I do the same thing in ctypes? ctypes.addressof(s_) +

Re: ctypes: reference of a struct member?

2009-05-01 Thread CTO
ctypes.byref() -- http://mail.python.org/mailman/listinfo/python-list

Re: ctypes: reference of a struct member?

2009-05-01 Thread ma
ctypes.byref() does not work for struct members. Try it out. class s(ctypes.Structure): _fields_ = [('x',ctypes.c_int)] a = s() ctypes.byref(a.x) //this won't work. On Fri, May 1, 2009 at 2:28 PM, CTO debat...@gmail.com wrote: ctypes.byref() --

Re: ctypes: reference of a struct member?

2009-05-01 Thread Günther Dietrich
ma mabdelka...@gmail.com wrote: If I have this struct in C: struct spam { int ham; char foo; }; if I have this declaration: struct spam s_; If I wanted to pass a reference to a function of s_'s foo character, I can do something like this: somefunc(s_.foo) How do I do the same thing

Re: ctypes: reference of a struct member?

2009-05-01 Thread Gabriel Genellina
En Fri, 01 May 2009 14:39:39 -0300, ma mabdelka...@gmail.com escribió: If I have this struct in C: struct spam { int ham; char foo; }; if I have this declaration: struct spam s_; If I wanted to pass a reference to a function of s_'s foo character, I can do something like this:

Re: ctypes: reference of a struct member?

2009-05-01 Thread Gabriel Genellina
En Sat, 02 May 2009 00:51:29 -0300, Gabriel Genellina gagsl-...@yahoo.com.ar escribió: En Fri, 01 May 2009 14:39:39 -0300, ma mabdelka...@gmail.com escribió: If I have this struct in C: struct spam { int ham; char foo; }; if I have this declaration: struct spam s_; If I wanted to