Lionel Data | 3 Aug 11:41 2010

Re: C++ wrapping : Template bug ?

2010/8/3 Lionel Data < <at>>
Hi, I am experiencing a strange behavior of Cython when trying to wrap STL containers.

I copy/pasted the code available here :

This works fine if I keep "int" as the template parameter. It still works fine if I put "int *".

If I now add:

cdef extern from "test.h":
    cdef cppclass TestClass:

below the list declaration, it still works fine with "TestClass" as the template param.

But surprisingly, it does not even compile to c++ if I write "TestClass *".
The error message is:

cdef vector[TestClass *] *v = new vector[TestClass *]()

/home/lionel/test/test_cython.pyx:21:23: Expected an identifier or literal

It seems like a bug, but I'm quite tired today so I might have missed something. If it is indeed a bug, what do you suggest as a workaround ?

(I use the repository "trunk" version)


Well, it wasn't that hard to fix after all, a "ctypedef struct PTestClass" did the job, along with a "typedef TestClass * PTestClass" in the .h file.