From: RobMarshall <Rob...@ig...> - 2010-03-29 18:18:02
|
OK, so I solved the problem myself by using a wrapper, e.g.: %rename(db_connect) PyDbConnect; %inline %{ db_store_internal *PyDbConnect(char *name) { db_store *store = NULL; db_connect(name, &store); return (db_store_internal *)store; %} It's actually a little more complicated than that because I keep a global list of open store's and free the memory via another wrapper that does the disconnect...but that's basically how I got around this. Rob RobMarshall wrote: > > Hi, > > I'm new to SWIG and I'm trying to use Python to access > a C library. One of the variables is defined as: > > typedef void db_store; > > When connecting to the database the call is: > > db_connect(char *name, db_store **store) > > When I create the shared library the definition of > db_store is never created, so when I try to do the > following in python: > > >>> store = db_store > > I get: > > NameError: name 'db_store' is not defined > > And if I simply try to call the connect I get: > > >>> db_connect("",store) > > NameError: name 'store' is not defined > > BTW, db_store ends up getting pointed at an internal > struct, db_store_internal, that has members and does > show up, but I can't use: > > >>> store = db_store_internal > >>> store > <class 'db.db_store_internal'> > >>> db_connect("",store) > > because it then says: > > TypeError: in method 'db_connect', argument 2 of type 'db_store **' > > How do I do this? > > Thanks, > > Rob > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user > > -- View this message in context: http://old.nabble.com/How-to-use-**void-tp28048517p28073116.html Sent from the swig-user mailing list archive at Nabble.com. |