我在cython头文件api.pxd
中定义了和enum
:
ctypedef enum InstructionType:
default = 0
end_if = 1
end_loop = 2
backward_jump_here = 4
我还检查了将ctypedef
转换为cdef
是否有效(但它没有)。在
我想在某个类的__cinit__
方法中使用此枚举中的值:
我得到了编译错误:
self.type = InstructionType.end_if
^
------------------------------------------------------------
/home/(...)/instructions.pyx:149:35: 'InstructionType' is not a constant,
有没有办法以这种方式定义和使用enum?在
不通过枚举常量访问枚举常量,它们既不属于C,也不在C++中,也不在Cython。你需要为它创建一个包装器pxd。在
相关问题 更多 >
编程相关推荐