[Cython] Invalid C++ with Python and C++ iterators (not compiling CLang)
Gael Varoquaux
gael.varoquaux at normalesup.org
Mon Feb 17 12:46:06 CET 2014
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
More information about the cython-devel
mailing list