access double pointer to a struct

28 views
Skip to first unread message

Oliver Wang

unread,
Nov 8, 2016, 8:45:59 PM11/8/16
to python-cffi
hi all


I have a library function in the form of:


typedef struct {
 
int fd;
} attr_t;


void read_attr( struct ** attr_t);




In C app, I would usually do:

attr_t  *myattr;
read_attr
( & myattr);




However, as I wrap it with cffi:

attr_dp = cffi.new("attr_t **")
read_attr
(attr_dp);



and I can't seem to get it right to access attr_t from this double pointer. Any idea?

thanks

Oliver

Oliver Wang

unread,
Nov 8, 2016, 9:16:48 PM11/8/16
to python-cffi
 
never mind, I made a mistake of using the returned pointer.

what I  should have done:

attr_p = attr_dp[0]
attr_p
.fd // will give me what I need.



Oliver


Reply all
Reply to author
Forward
0 new messages