From mint-bounce@lists.fishpool.fi Sun Jan 11 10:35:08 2009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=kXOZMOLEdnwZc5i0CpRvt7aFC+1bqiyroolv2oy1utk=; b=tVivUuLS9nIMk56Xa525z+MOKJDpH6tLmZJQEvzQLEf/P6u8bHboo+GmM3lTKRZvQO p6Uw4dKGmlzr0AzXz0sDFN+MzVNEOd2JphjKwzhuY3XCJeIjcLr0OEsvxa0l3Se8aJOZ rJy9acWDSYgAJo/rZPk7TUFeXzu63z9qf7v4U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=aMJSoMjLS+B6bdtC2M6wIXoDbmAZ9p7QWsFAL8O8yslsjJCsGrondu63bI6OeqbymU +0Kd23zC5fmmxrO0LrEl5py9K9jFgR6RjddIvvM28hVd0RK83chBuJlmMWVpJnILfKlY EM/pOkg+9LTtjtlWNj/gS/rOYnPbD0uWBMDDw= Message-ID: Date: Sun, 11 Jan 2009 16:27:11 +0100 From: "Miro Kropacek" To: "Mint list" Subject: [MiNT] struct align MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_172024_11365442.1231687631956" X-ecartis-version: Ecartis v1.0.0 Sender: mint-bounce@lists.fishpool.fi Errors-to: mint-bounce@lists.fishpool.fi X-original-sender: miro.kropacek@gmail.com Precedence: bulk List-help: List-unsubscribe: List-Id: X-List-ID: List-subscribe: List-owner: List-post: ------=_Part_172024_11365442.1231687631956 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, I've found this thing while coding some stuff: #include struct { char x; short y; char v; long z; char u; } a; int main(void) { printf( "%p %p %p %p %p %d\n", &a.x, &a.y, &a.v, &a.z, &a.u, sizeof(a) ); return 0; } when I run this on Atari with the newest gcc (and vbcc as well), I've got: 0x1e43d58 0x1e43d5a 0x1e43d5c 0x1e43d5e 0x1e43d62 12 for vbcc and 0x1e58988 0x1e5898a 0x1e5898c 0x1e5898e 0x1e58992 12 for gcc But on linux gcc: 0x80495b8 0x80495ba 0x80495bc 0x80495c0 0x80495c4 16 You see -- the 3rd member is put xxxxxC address (i.e. divisible by 4), fine. But now, on both atari compilers is then 'long' member aligned on 2 bytes (xxxxE, which is 14 for x = 0, i.e. divisible only by 2) what I find wrong since it should work according to the data type (char = aligned on 1 byte boundary, short = 2 bytes, long = 4 bytes, ...) and this assumption supports the fact it works in that way on linux's gcc. But I have no idea, what's wrong here? linker setup or gcc setup? -- MiKRO / Mystic Bytes http://mikro.atari.org ------=_Part_172024_11365442.1231687631956 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi,

I've found this thing while coding some stuff:

#include <stdio.h>

struct
{
        char x;
        short y;
        char v;
        long z;
        char u;
} a;

int main(void)
{
        printf( "%p %p %p %p %p %d\n", &a.x, &a.y, &a.v, &a.z, &a.u, sizeof(a) );
        return 0;
}

when I run this on Atari with the newest gcc (and vbcc as well), I've got:

0x1e43d58 0x1e43d5a 0x1e43d5c 0x1e43d5e 0x1e43d62 12 for vbcc
and
0x1e58988 0x1e5898a 0x1e5898c 0x1e5898e 0x1e58992 12 for gcc

But on linux gcc:

0x80495b8 0x80495ba 0x80495bc 0x80495c0 0x80495c4 16

You see -- the 3rd member is put xxxxxC address (i.e. divisible by 4), fine. But now, on both atari compilers is then 'long' member aligned on 2 bytes (xxxxE, which is 14 for x = 0, i.e. divisible only by 2) what I find wrong since it should work according to the data type (char = aligned on 1 byte boundary, short = 2 bytes, long = 4 bytes, ...) and this assumption supports the fact it works in that way on linux's gcc. But I have no idea, what's wrong here? linker setup or gcc setup?

--
MiKRO / Mystic Bytes
http://mikro.atari.org
------=_Part_172024_11365442.1231687631956--