🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.programmer.codewarrior
Article #828

Re: Alignment (padding) of derived classes, Mach-O vs. CFM

#828
From: Thorrsten Froehlich
Date: Fri, 20 Jun 2003 19:35
32 lines
2609 bytes
stk@snafu.de (Stefan Haller) wrote in message news:<1fwrc5z.1wbucc58vha4aN%stk@snafu.de>...
> We need to pass objects between a Mach-O application and a CFM shared
> library, built from the same source code.
> 
> It seems that the Mach-O and CFM compilers behave differently with
> regard to the alignment of derived classes, so that the object layout is
> different.  Obviously this is a serious problem for us.
> 
> The following sample code illustrates the problem.  I don't understand
> what the padding rules are here; CFM doesn't *always* pad so that the
> derived class starts on the next 8-byte boundary, because if you comment
> out the "int i" in Base, the offset of b2 is 1 on both compilers.

Actually, a minimal padding can be a good thing if you need to a lot
of small objects.  Anyway, I see your problem is similar to one I have
been having some time ago (but not directly related, I had stack
alignment issues in my own code generated at runtime when interfacing
to CW functions).

> Is this a bug in one of the compilers?

No, the ABI is different, and it is actually documented what is being
used. Not in any of the manuals as I just noticed, also I thought I
had read it there. There are more options for alignment, and they are
not documented in the compiler manual yet, it seems:
You find them in "CW Mac PPC Notes 3.0.txt" in the Release Notes
folder. If you play with them a bit, in particular the "power_gcc"
options, I guess you get what you want assuming Apple and Metrowerks
follow the same revision gcc ABI for Mach-O to be compatible with each
other.

    Thorsten
Technical Details
Message-ID: <a1ed16f9.0306201135.5802e437@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail
References: <1fwrc5z.1wbucc58vha4aN%stk@snafu.de>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f635e,98e56c06675247cc
X-Google-Attributes: gidf635e,public
X-Google-Thread: 10bcce,98e56c06675247cc
X-Google-Attributes: gid10bcce,public
X-Google-ArrivalTime: 2003-06-20 12:35:38 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: 20 Jun 2003 12:35:37 -0700
Organization: http://groups.google.com/
Lines: 32
Message-ID: <a1ed16f9.0306201135.5802e437@posting.google.com>
References: <1fwrc5z.1wbucc58vha4aN%stk@snafu.de>
NNTP-Posting-Host: 213.23.176.134
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1056137738 11645 127.0.0.1 (20 Jun 2003 19:35:38 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 20 Jun 2003 19:35:38 GMT