It might not strictly be required, but I'd add:
%ModuleHeaderCode
#include <word.h>
%End
after the %CModule line (although it seems like you'd get compile errors >if it
was really necessary - might depend on whether sip generated code >is concatenated
for compiling or not).
You might also try:
Word *create_word(const char *);
char *reverse(Word *);
char *myReverse(const char *);
removing "struct" in two places (not sure if it's required or makes a
difference as far as sip is concerned - I believe it's not necessary >though).
Also, in Python, try printing w.the_word before calling reverse.
You could also try making Word a class:
class Word
{
public:
char *the_word;
};
At one time (long ago) I had problems doing structs with sip, but I think
that's been fixed for quite a while.
Otherwise, I don't see any obvious errors in the sip file. I'd also look >at how
the module is linked and if the .so file being wrapped can be >found at runtime.
Jim
Thank you Jim for the reply. Here is the screen snapshot for what I did:
Python 2.3.4 (#2, Aug 19 2004, 15:49:40)
[GCC 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import word
print word.myReverse("sadkfj;sadf")
fdas;jfkdas
print word.__dict__
{'create_word': <built-in function create_word>, 'Word': <class
'word.Word'>, 'reverse': <built-in function reverse>, '__file__': 'word.so',
'myReverse': <built-in function myReverse>, '__name__': 'word', '__doc__':
None}
w = word.create_word("How are you?")
print w
<word.Word object at 0x4038fddc>
print word.reverse(w)
Segmentation fault
So you can see that the "struct Word" was mapped to a Python class, and the
function "myReverse()" just works fine, which means it does find the .so
file correctly.
BTW, I tried what you suggested by removing the key word "struct" and adding
the %ModuleHeaderCode....", it doesn't have any visuable effect.
Huaicai
_______________________________________________
PyKDE mailing list [email protected]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde