From: William S F. <ws...@fu...> - 2011-10-07 19:50:19
|
On 27/09/11 17:29, Stefan Zager wrote: > On Mon, Sep 26, 2011 at 4:38 PM, Bailey Miller > <bai...@gm...> wrote: >> Hello, thanks in advance for any help. >> 1) >> I have a c++ header file which contains an enumeration: >> enum animal { monkey, chimp, ... }; >> The header file also contains a function definition: >> int noise (const char* name, int number_of_noses, animal a); >> SWIG generates an interface, and correctly makes the enumerated values >> available, but when I try to use the function in python: >> >> handle = interface.noise("test", 2, interface.monkey) >> Python says that I am using the wrong type or number of arguments and kindly >> lists the available prototypes. It does not seem that SWIG is getting the >> typemapping correct. Any tips? > > This might work, in your interface file before the enum declaration: > > %apply int animal; > That shouldn't be necessary as SWIG should generate code so that you can pass in enum constants to the function without having to do anything extra. Probably what has happened is that the enum declaration has not been parsed by SWIG or it was parsed after the declaration of noise. Use swig -E to look at the preprocessed output to check. William |