Re: [cairo] Re: Notes on cairo/win32



On Fri, 14 Jan 2005 11:21:02 -0500, Owen Taylor <otaylor redhat com> wrote:
> 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.
> 
> I'd be suprised if the Rect class didn't have the memory layout:
> 
> struct Rect_ {
>    int x, y, width, height;
> }

That is indeed true -- struct vs class affects only default visibility
of members, and a given C-legal struct definition (no virtuals, f.e.)
should produce the same layout when compiled as C++.

It is certainly possible for a C++ compiler to use different padding
rules than another C compiler, but for a given single compiler to
produce different layouts would render C libraries largely unusable
from C++; I'm comfortable labelling that as ridiculously unlikely.

Mike



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]