[Pyrex] [Mac Inter Core Duo OS 10.4.9 ] extern C class decl. requires module specification

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Jun 15 01:00:31 UTC 2007


David Goldsmith wrote:

> OK, so now I'm going to have to bone up on precisely what features 
> classes support that structs don't (e.g., I used to think that member 
> functions was on that list, then I learned that structs do support that;

In C++, they do -- structs and classes are the same thing.
The only difference is the default visibility of members.

But Pyrex knows nothing about C++, and sees them as *C*
structs, which of course don't have any C++ features.

Despite this, some things may happen to work anyway --
e.g. declaring a struct as having a member function,
which Pyrex treats as though it were a function pointer.
It's not really, but you get the right result in the
end.

There are also some tricks you can pull with C names
to fool Pyrex into calling C++ constructors and such
like. I don't have an example to hand, but someone on
the Pyrex list should be able to help you.

> Potentially, I don't really have a problem, as the legacy code I'm 
> wrapping is devoid of classes

If they're used simply as C structs, with no member
functions, constructors, etc., there shouldn't be any
problem.

--
Greg



More information about the Pyrex mailing list