[cairo] Re: Notes on cairo/win32

Dave Malcolm dmalcolm at redhat.com
Fri Jan 14 10:05:37 PST 2005


On Fri, 2005-01-14 at 11:21, Owen Taylor wrote:
> On Fri, 2005-01-14 at 16:07 +0000, J. Ali Harlow wrote:
> > On 13/01/05 22:06:46, J. Ali Harlow wrote:
> > > On 13/01/05 20:27:43, Owen Taylor wrote:
> > > 
> > > > I think that the claim is that the flat API is C++ based too...
> > > 
> > > Concern, at least, yes.
> > > 
> > > > GpPath *is* defined as a class, but only in the most trivial way.
> > > > As far as I can see, it's really just an opaque pointer and you
> > > > could use a C definition like:
> > > >
> > > >  typedef struct GpPath_ GpPath;
> > > >
> > > > and it should work fine.
> > > 
> > > Let's hope you're right. I'll try and have a play tomorrow and see if
> > > I can put together a gdiplusflat.h which uses opaque pointers or  
> > > drops functions that take classes that appear to be wrappers  
> > > themselves (eg., GdipAddPathRectanglesI which probably just wraps
> > > GdipAddPathRectangleI).
> > 
> > Okay, I've had a quick play. It's possible to produce header files  
> > which will compile with a C compiler as long as you avoid certain  
> > functions which use the C++ '&' operator. Mine are pretty raw, but if  
> > anybody wants them, please shout.
> > 
> > However, in trying to use these headers to compile a test program[1], I  
> > ran into trouble with trying to lock a bitmap. It seems as though you  
> > have to have a Rect (which is a class) to lock a bitmap and there is no  
> > way to create one in C.
> > 
> > Some half-baked ideas for how to proceed:
> > 
> > - It's possible that you could try and hack one up using a structure if  
> > you assumed that the public members came at the start but I've no idea  
> > if this would work and in any case it doesn't sound like a sensible way  
> > to proceed to me.
> 
> I have some belief that a C++ class is required to have the same 
> in-memory layout as a C structure with the same members in the same
> order.
(provided you don't have any virtual functions, or RTTI, right?)

> 
> I'd be suprised if the Rect class didn't have the memory layout:
> 
> struct Rect_ {
>    int x, y, width, height;
> }
> 
> having private members would just be weird for that.

[snip]




More information about the cairo mailing list