Forward Declaring Py_complex

Mark Charsley mark.charsley at REMOVE_THIS.radioscape.com
Thu Jul 4 11:38:00 EDT 2002


In article <3VYU8.600843$Oa1.37637572 at bin8.nnrp.aus1.giganews.com>, 
tjreedy at udel.edu (Terry Reedy) wrote:

> 
> "Mark Charsley" <mark.charsley at REMOVE_THIS.radioscape.com> wrote in
> message news:memo.20020704104527.604A at a.a...
> ...
> > for it, and don't treat it as a syntax error" then I can avoid
> having to
> > force all my class's clients from having to pull in a lot of header
> files
> > that most of them don't care about. This will have two benefits:
> > 1) build times won't be hit by having to process unnecessary headers
> for
> > each cpp file
> > 2) my workmates won't spend the next week moaning that I've broken
> their
> > build and asking which directories they have to put in their
> project's
> > include path to fix it.
> 
> Given these desiderata, I would consider handcrafting a minimal
> 'mypyplex.h' include with just the stuff needed, even knowing that it
> might break and need editing for some future version of Python.

Alas that doesn't work...

MyClass.h includes MyPyPlex.h, which defines Py_Complex. 
MyClass.cpp includes MyClass.h and Python.h which also defines PyComplex

My compiler complains about multiple definitions of PyComplex. How does 
one go about putting in a Change Request/PEP/whatever asking for 
ComplexObject.h to be changed so that Py_Complex can be forward declared.

My C (with no ++ at all) skills are a little rusty, but I think changing

typedef struct {
    double real;
    double imag;
} Py_complex;


to either 

typedef struct TAG_Py_complex {
    double real;
    double imag;
} Py_complex;

or failing that

#ifdef __cplusplus
    struct {
        double real;
        double imag;
    } Py_complex;

#else
    typedef struct {
        double real;
        double imag;
    } Py_complex;
#endif

would solve the problem.

-- 

Mark - personal opinion only, could well be wrong, not representing 
company, don't sue us etc. etc.



More information about the Python-list mailing list