[Pyrex] Same type does not resolve to itself when coming in through different .pxd files

Dan Gindikin dg at pnylab.com
Wed Nov 14 17:06:21 CET 2007


A "cdef struct", defined in a .pxi file, when imported through different .pxd
files, does not equal itself in type comparisons (presumably it does not resolve
to the same thing because it comes in through different .pxd's).

Here are the files:
	
	my.pxi
		# the type in question, F, is defined here

		cdef extern from "stdio.h":
			cdef struct f:
				int j
				
			#ctypedef int F		# works
			ctypedef f F		# doesn't work
			
	mymodule.pxd
		
		# here is F the first time
		include "my.pxi"
		
		cdef class base:
		    cdef void func(self, F x)
		
	
	main.pxd
	
		# here is F again
		include "my.pxi"

		cimport mymodule

		cdef class derived(mymodule.base):
			
			# This line causes a "Signature does not match previous
			# declaration", the F here is being compared to the F
			# that comes from the definition of base.func from
			# mymodule.pxd, and the comparison says they are
			# different
			cdef void func(self, F x)
			
	main.px
			
		include "my.pxi"

		import mymodule

		cdef class derived(mymodule.base):
			cdef void func(self, F x):
				pass

-- 
Dan



More information about the Pyrex mailing list