[Cython] Invalid C++ with Python and C++ iterators (not compiling CLang)

Robert Bradshaw robertwb at gmail.com
Fri Feb 21 22:12:13 CET 2014


For reference, this has been fixed:
https://groups.google.com/forum/#!topic/cython-users/2GO2_JRXr9s

On Mon, Feb 17, 2014 at 3:46 AM, Gael Varoquaux
<gael.varoquaux at normalesup.org> wrote:
> Hi,
>
> I'd like to enquire on the status of the problem raised last year:
> https://mail.python.org/pipermail/cython-devel/2013-April/003629.html
>
> To summarize, the following Cython leads to code that doesn't compile
> with Clang and is probably invalid C++:
>
>     from libcpp.vector cimport vector as libcpp_vector
>     from cython.operator cimport dereference as deref, preincrement as inc
>
>     cdef class TestClass:
>
>         cdef libcpp_vector[float] inst
>
>         def __iter__(self):
>             it = self.inst.begin()
>             while it != self.inst.end():
>                 yield deref(it)
>                 inc(it)
>
> This create the following C++ code:
>
>   p->__pyx_v_it.std::vector<float>::iterator::~iterator();
>
> which is invalid, but happens to work on GCC and MSVC. However, Clang
> support is starting to become very important, as it is the default
> compiler on MacOSX.
>
> The original reporter suggested a valid C++ code (see original email),
> which wasn't very convenient as it required a typedef.
>
> Any progress on the issue or suggestion to work around?
>
> Cheers,
>
> Gaël
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> https://mail.python.org/mailman/listinfo/cython-devel


More information about the cython-devel mailing list