Article View: comp.sys.mac.programmer.codewarrior
Article #804Re: Alignment (padding) of derived classes, Mach-O vs. CFM
From: Thorrsten Froehlich
Date: Wed, 25 Jun 2003 07:41
Date: Wed, 25 Jun 2003 07:41
33 lines
2565 bytes
2565 bytes
Miro Jurisic <macdev@meeroh.org> wrote in message news:<macdev-7428E9.22150424062003@senator-bedfellow.mit.edu>...
> In article <1fwrc5z.1wbucc58vha4aN%stk@snafu.de>, stk@snafu.de (Stefan Haller)
> wrote:
>
> > We need to pass objects between a Mach-O application and a CFM shared
> > library, built from the same source code.
>
> You are doomed. It will never work because the vtbl layout and offsets to base
> classes are different.
But that should be all, and according to his observations, data within
the class is also aligned differently and independent of the struct
alignment compiler options.
So assuming one can get the alignment of member data to match (which
he says he cannot change except to byte alignment using pack(1)), one
can at least pass data. He didn't say he wants to make calls to member
functions, so only the vtable pointer size matters, but not the
content of the vtable structure. As both ABIs use a single pointer for
the vtable pointer, and specify that data memebrs are aligned
following that pointer, imho there is nothing unreasonable about
assuming one can exchange data this way. The only potential problem
then would be different rules for data placement in the multiple
inheritance case.
So the question is why the alignment of data members can be set to
pack(1) and then it works as expected, but as he observed, not changed
otherwise?
Thorsten
Note: I did not test myself that the alignment does not change for
C++, I take his word for this.
Technical Details
Message-ID:
<a1ed16f9.0306242341.2758dd3d@posting.google.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mailReferences:
<1fwrc5z.1wbucc58vha4aN%stk@snafu.de> <macdev-7428E9.22150424062003@senator-bedfellow.mit.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10bcce,98e56c06675247cc X-Google-Attributes: gid10bcce,public X-Google-Thread: f635e,98e56c06675247cc X-Google-Attributes: gidf635e,public X-Google-ArrivalTime: 2003-06-25 00:41:16 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail From: froetho@charlie.iit.edu (Thorrsten Froehlich) Newsgroups: comp.sys.mac.programmer.codewarrior,codewarrior.mac Subject: Re: Alignment (padding) of derived classes, Mach-O vs. CFM Date: 25 Jun 2003 00:41:15 -0700 Organization: http://groups.google.com/ Lines: 33 Message-ID: <a1ed16f9.0306242341.2758dd3d@posting.google.com> References: <1fwrc5z.1wbucc58vha4aN%stk@snafu.de> <macdev-7428E9.22150424062003@senator-bedfellow.mit.edu> NNTP-Posting-Host: 213.23.167.99 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1056526876 22179 127.0.0.1 (25 Jun 2003 07:41:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 25 Jun 2003 07:41:16 GMT