1 Feb 15:09
Declaring pointers to pointers C->Python
Paul Griffiths-Todd <Paul.Griffiths-Todd <at> high-availability.com>
2012-02-01 14:09:53 GMT
2012-02-01 14:09:53 GMT
Hi,
I am trying to use a pointer to a pointer in Python but I cannot seem to work out the correct syntax, the declaration for the C functions is:
typedef struct _GroupList
{
uint32_t cnt;
char *name[1];
} GroupList;
int getGroupList(GroupList **myGroupList);
It's a supplied system call so I cannot change the argument call. In python I do:
import example
GroupList = example.GroupList()
print GroupList
example.getGroupList( GroupList )
Which results in:
<example.GroupList; proxy of <Swig Object of type 'GroupList *' at 0x81679b0> >
Traceback (most recent call last):
File "test.py", line 7, in <module>
example.getGroupList( GroupList )
TypeError: in method 'getGroupList', argument 1 of type 'GroupList **'
I just cannot work out how to get a pointer to a pointer rather than just a pointer (and I do understand why I just get a pointer) - any help would be most appreciated.
Many Thanks,
Paul Griffiths
I am trying to use a pointer to a pointer in Python but I cannot seem to work out the correct syntax, the declaration for the C functions is:
typedef struct _GroupList
{
uint32_t cnt;
char *name[1];
} GroupList;
int getGroupList(GroupList **myGroupList);
It's a supplied system call so I cannot change the argument call. In python I do:
import example
GroupList = example.GroupList()
print GroupList
example.getGroupList( GroupList )
Which results in:
<example.GroupList; proxy of <Swig Object of type 'GroupList *' at 0x81679b0> >
Traceback (most recent call last):
File "test.py", line 7, in <module>
example.getGroupList( GroupList )
TypeError: in method 'getGroupList', argument 1 of type 'GroupList **'
I just cannot work out how to get a pointer to a pointer rather than just a pointer (and I do understand why I just get a pointer) - any help would be most appreciated.
Many Thanks,
Paul Griffiths
------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________ Swig-user mailing list Swig-user <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/swig-user
RSS Feed