On Thu, Jul 16, 2015 at 2:13 PM, Brian McAndrews <brian.mcandr...@chicagotrading.com> wrote: > I have a C enum type that I’m attempting to put in a C++ map:
Interesting, thanks for the report. Fixed at https://github.com/cython/cython/commit/427771298da04f0f5bb61659ddf4a61bd0f02af4 > Here’s what I got: > > > > colors.h: > > enum Color > > { > > GREEN,BLUE,RED > > }; > > > > val.pyx: > > from libcpp.string cimport string > > from libcpp.map cimport map > > > > cdef extern from "colors.h": > > cpdef enum _Color "Color": > > GREEN,BLUE,RED > > > > cdef class TestMe: > > cdef public map[string, _Color] vals > > > > > > I get a compile error (VSC++ 2012) > > VAL.cpp(1239) : error C2440: '=' : cannot convert from 'long' to 'Color' > > Conversion to enumeration type requires an explicit cast > (static_cast, C-style cast or function-style cast) > > > > The offending statement is this: > > __pyx_t_9 = PyInt_AsLong(__pyx_v_value); if (unlikely(PyErr_Occurred())) > {__pyx_filename = __pyx_f[1]; __pyx_lineno = 202; __pyx_clineno = __LINE__; > goto __pyx_L1_error;} > > > > In the __pyx_convert_map_from_py_std_3a__3a_string__and_enum__Color > function. > > > > The cast from PyInt_AsLong(…) to an enum Color is not specified when using > maps. > > > > If I don’t put it in a map (just as a member variable), the cast is > performed. > > > > Has anyone seen this before? > > > > Thanks, > > Brian > > > > > > > > This electronic mail message and any attached files contain information > intended for the exclusive use of the individual or entity to whom it is > addressed and may contain information that is proprietary, confidential > and/or exempt from disclosure under applicable law. If you are not the > intended recipient, you are hereby notified that any viewing, copying, > disclosure or distribution of this information may be subject to legal > restriction or sanction. Please notify the sender, by electronic mail or > telephone, of any unintended recipients and delete the original message > without making any copies. > > > _______________________________________________ > cython-devel mailing list > cython-devel@python.org > https://mail.python.org/mailman/listinfo/cython-devel > _______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel