From: steve W. <ste...@gm...> - 2009-04-24 15:46:04
|
Hi again! I checked if this should be a C++ compiler error but doesn't seem like it is a compiler error because I'm able to do stuff from the Python interpreter without any errors. A Python int variable is accepted by the C++ function whose argument is typedef'd. But the same function does not work in a Python program. I was assuming that if it worked in the interpreter, it should work when used in a python program. This however doesn't seem to happen. Do you see any reason why this is happening? Thanks for your help! Steve On Tue, Apr 21, 2009 at 8:01 PM, William S Fulton <ws...@fu...>wrote: > steve William wrote: > >> Thanks for replying. >> >> While going through the SWIG documentation I got to know that typedef can >> actually be used in the interface file for indicating the native data type >> that the specified name corresponds to so that SWIG can do the mapping. It >> says that the definition of typedef in the interface file must be like: >> typedef <basic type> <new name> >> eg. typedef unsigned int new_type; >> >> I tried doing this and checked the c wrapper that swig generates. It has >> the typedef declared in the interface file. However I still get an error >> saying: >> TypeError: in method 'function', argument 1 of type 'new_type' >> >> Sounds like you need to add the typedef to your C++ code as that looks > like a C++ compiler error. Maybe you should post a little interface file > with an example of what the problem is you are having. > > Also I'm not sure on how to use %rename. Could you point me to some >> documentation that shows how and where %rename is to be used? >> >> grep "%rename" Doc/Manual/*.html > http://www.google.com/search?q=swig+%25rename works quite well too. > > Thanks, >> Steve >> >> On Wed, Apr 15, 2009 at 7:16 PM, William S Fulton < >> ws...@fu... <mailto:ws...@fu...>> wrote: >> >> steve William wrote: >> >> Hi All, >> >> I am facing this issue when I pass arguments whose data types >> have been assigned another name using "typedef". Python >> interpreter gives an error when I try to pass a python variable >> to a C++ function whose argument has been declared using a >> typedef data type. The base data type of the argument is long. >> >> What could be done to overcome this issue?? Is it that I cannot >> pass a typedef argument from python to C++. >> Any help is highly appreciated! >> >> SWIG generates code such that only one name can be used from Python. >> The default name chosen is the resolved name (ie not the typedef >> name, with one exception when a struct is typedef'd and declared in >> one statement). You can change the name used in the target language >> with %rename. >> >> William >> >> >> > |