[Pyrex] C++ forward declaration

Ravi Lanka ravi_lanka at acusim.com
Fri Apr 4 01:20:27 CEST 2008


Pyrex gurus,

   I am trying to wrap two C++ classes in a Namespace called 
"MyNameSpace".  I was breezing through using some of the ideas shared by 
Lenard and others.  I got stuck with a case of forward declaration as 
below.  The two classes I have, A and B, have methods that require the 
objects corresponding to B and A.  If I try to declare, say class B, 
without all the methods before class A and then try to create the 
complete code for class B, it complains that class B is re-declared.  
How do I get around this problem ?

cdef extern from "A.h":
    ctypedef struct A "MyNameSpace::A":
        void (*foo)( B data )

cdef extern from "B.h":
    ctypedef struct B "MyNameSpace::B":
        void (*bar)( A data )

thanks
Ravi



More information about the Pyrex mailing list