On Wed, Nov 11, 2009 at 3:05 PM, J. Jankins <[email protected]> wrote:
>
>
> Hello,
>
> I am trying to use C++ STL, specifically container <vector> and <set>. But I 
> just find a little discription in <Cython Manual>. And I couldn't even to get 
> the example to work.
>
> Here is what I do:
> 1. <stl.h>:
> #include <vector>
>
> 2. <pstl.pyx>:
>    cdef extern from "stl.h":
>        ctypedef struct intvec "std::vector<int>":
>            void (* push_back) (int elem)
>        intvec intvec_factory "std::vector<int>" (int len)
>
>    def main():
>        cdef intvec v = intvec_factory(2)
>        v.push_back(3)
>        print 'Hello'
>
> 3.<setup.py>:
>  from distutils.core import setup
>  from distutils.extension import Extension
>  from Cython.Distutils import build_ext
>
>  setup(
>    name = 'Demos',
>    ext_modules=[
>      Extension("test",
>                sources=["pstl.pyx"],
>                include_dirs=["."],
>                language="c++"),
>      ],
>    cmdclass = {'build_ext': build_ext},
> )


i think if you change "test" to "pstl" your example will work.
-brent

>
>
> 4. python setup.py build_ext --inplace
>
> When I import "pstl", there is an  ImportError.
>
> I am totally frustrated. And I commit that: I didn't finish reading Cython 
> Manual. It's not that easy to understand and it has too few examples.
>
> Thanks.
>
> Jankins
>
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev
>
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to