[PyKDE] sip undefined type

Phil Thompson phil at riverbankcomputing.co.uk
Wed Feb 16 09:05:23 GMT 2005


> Sirs:
>
> I am trying to wrap the xbase c++ library so I can handle ca clipper xbase
> files from python.  (If anyone out there has a better suggestion I am all
> ears.)
>
> When I try to run sip against my wrapper class I get an error similar to
> the
> following (different type, same error)
>
> sip -c . pytest.sip
> sip: std::string is undefined
>
> This actual error is from running the following sip file, against the
> following c++ code.
>
> I have written a small test class, a rather crude stack in c++ and was
> able to
> wrap it with sip.  When I added a string variable, it died with the above
> error.
> **********************************************
> pytest.sip
>
> %Module pytest 0
>
> class Stack
> {
>
> %TypeHeaderCode
> #include "test4.h"
> %End
>
> public:
>   std::string foo;
>   Stack();
>
>   void push(const int);
>   int pop();
>
> *************************************************
>
> test4.h
> #include <string>
>
> class Stack
> {
> private:
>   int count;
>   int data[100];
>
> public:
>   std::string foo;
>   Stack();
>
>   void push(const int item);
>   int pop();
>
> };
>
> ***************************************************************
>
> test4.cpp
> #include "test4.h"
>
> Stack::Stack()
> {
>   count = 0;
> };
>
>
> void Stack::push(const int item)
> {
>   data[count] = item;
>   count++;
>
> };
>
> int Stack::pop()
> {
>   count--;
>   return data[count];
> };
> *****************************************************************
>
> This code compiles and links just fine in c++
> I can create a lib file and call it from a c++ program.
> If I remove the string foo; line, I can sip it and use it from python.
>
> I am an excelent programmer in clipper, a passable programer in python and
> an
> amature in c++.
>
> I would be more than glad to rtfm if I had a hint about which fm and where
> to
> look.  I have looked thru the last 6 months or so of the mailing list
> archives without any hints.
>
> It would seem as if there is something I am missing somewhere, simple and
> obvious that I am looking past.

SIP doesn't know anything about std::string - you have to wrap it.

Phil




More information about the PyQt mailing list