[Pyrex] Possible bug with ctypedef'ed enum

Matt Hammond matt.hammond at rd.bbc.co.uk
Thu Nov 8 10:16:54 CET 2007


Hi,

After not having touched some pyrex code for a while, I tried recompiling  
some existing code and have come across a possible bug when using ctypedef  
on enums. I've experienced this both with 0.9.5.1a (as shipped in a  
package with ubuntu 7.10) and 0.9.6.3 which I downloaded the .tar.gz for  
last night.

The following code compiles fine:

	ctypedef int int_type
	ctypedef int_type int2_type
	
	def test():
	    cdef int_type  x
	    cdef int2_type y
	    x=5
	    y=7
	    if (x==y):
	        x=6
	
But the following does not:

	ctypedef enum enum_type:
	    AAA
	    BBB
	
	ctypedef enum_type enum2_type
	
	def test2():
	    cdef enum_type  p
	    cdef enum2_type q
	    p=AAA
	    q=BBB
	    if (p==q):
	        p=BBB

Returning the error:

	Invalid types for '==' (enum_type, typedef-fault.enum2_type)

I'm 99% sure that this used to compile fine under 0.9.4.

Its fairly easy to work around this, by simply dropping the typedef to  
enum2_type and using enum_type throughout. However it would be nicer not  
to the particular code I'm recompiling are bindings to a library, for  
which I'd rather reflect the original type structure (for clarity if  
nothing else).

cheers


Matt

-- 
| Matt Hammond
| Research Engineer, FM&T, BBC, Kingswood Warren, Tadworth, Surrey, UK
| http://www.bbc.co.uk/rd/



More information about the Pyrex mailing list