On Wed, 28 Apr 2004, David Mattes wrote:

> For some reason on the ARM processor the line in libusb-0.1.8/linux.c:
>     ret = read(fd, (void *)&dev->descriptor, sizeof(dev->descriptor))
> sizeof(dev->descriptor) is returning 20 instead of 18!!!  I have no idea
> why this might be happening as everything checks out and the sum of all
> the sizeof(dev->descriptor.*) adds up to 18!!!
>
> Anyway the hack is to subtract 2 from the amount to be read from fd and
> everything is golden again...   any ideas???

The C compiler is allowed to pad structures to satisfy the ABI's
alignment constraints.

For example, on a machine where int need to be aligned, the structure:

  struct foo {int a; char b;};

will be padded with 3 bytes, otherwise you would get alignment faults
on constructs like

    struct foo {int a; char b;} bar[2];
    bar[1].a = 23;

And the sizeof operator returns the size including padding...

   /Krister
_______________________________________________
Muscle mailing list
[EMAIL PROTECTED]
http://lists.drizzle.com/mailman/listinfo/muscle

Reply via email to