Re: [patch-2.4.0-test2]Re: Linux-2.4.0-test2

From: Tigran Aivazian (tigran@veritas.com)
Date: Sat Jun 24 2000 - 11:58:17 EST


On Sat, 24 Jun 2000, Xuan Baldauf wrote:
> Currently, I have no reference (but common sense), but AFAIK "+1" means "increment
> the pointer by 1 (byte)", not "increment the pointer by one storage unit (4
> bytes)".

incorrect. what do you think this trivial program prints:

struct foo {
        int x;
        int y;
} bar;

int main(int argc, char *argv[])
{
        struct foo *ptr;

        ptr = &bar;
        printf("ptr=%x\n", ptr);
        ptr = ptr + 1;
        printf("ptr=%x\n", ptr);
        return 0;
}

$ ./ptr
ptr=8049560
ptr=8049568

so, +1 means "increment the pointer by 1 storage unit (8 bytes in this
case)". However, pointer arithmetics is not relevant to how different
members of a given structure are packed.

(dropped Linus+Alan as I think it is safe to assume they know basic
C pointer arithmetics :)

Regards,
Tigran

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jun 26 2000 - 21:00:04 EST