Re: Working char ** variables
William S Fulton <[email protected]>
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CANGqftDMdMyU9R6mCoO4bY3Bptrd5dM6DqhQ72Fj7g-wTs0+hA@mail.gmail.com> |
On Thu, 3 Sep 2020 at 23:17, Ervin Hegedüs <[email protected]> wrote: > Hi there, > > I have a global variable with list of C strings: > > char ** custom_variables; > > with a method to append a new item to the end: > > void add_item_to_array(char *** arr, char * item); > > (this is how I call it: > add_item_to_array(&custom_variables, "foo") > ) > > I can access this variable in Python, and what I set I can see in > the running code, eg: > > mytest.cvar.custom_variables = ["Foo", "bar"] > > and I get what I want. > > > I'd like to use that list with .append() method, so I think I > have two ways - but I don't know the first (use list.append()), > and the second (use > mytest.add_item_to_array(mytest.cvar.custom_variable, "foo")) > drops an error: > > > Traceback (most recent call last): > File "./py3test.py", line 52, in <module> > mytest.add_item_to_array(mytest.cvar.custom_variables, "FooBar") > File "../../mytest.py", line 207, in add_item_to_array > return _mytest.add_item_to_array(arr, item) > TypeError: in method 'add_item_to_array', argument 1 of type 'char ***' > > > Which typemap have to I use and how? > > Hi Ervin The types for your typemaps need to be char***. It depends on a few things as to which typemaps you need, but probably just the 'in' typemaps. The Typemaps documentation chapter has lots of details. I strongly suggest reading about the debugging options, such as -debug-tmsearch. William _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user