Re: defining big types on avr-gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Il giorno mer, 04/08/2010 alle 10.35 +0100, Andrew Haley ha scritto:
> > I never read or write data poined by p. I only use it to calculate
> > offset of fields inside it.
> 
> It's still pretty dubious.  Why not use offsetof?
offsetof is defined as follows:
#define offsetof(st, m) \
    ((size_t) ( (char *)&((st *)(0))->m - (char *)0 ))

this gives me the warning:
'integer overflow in expression'
when I call:
offsetof(big_dummy_t, singledata);

for that reason I start to try in different way.

do you mean __builtin_offsetof()?

> > I could write:
> > uint16_t p = (uint16_t)((char *)&(p->singledata) - (char*)0);
> 
> You could, but that's undefined too: you can only subtract pointers
> that are part of the same array.
> 
> But I don't see the point of this anyway.  You can easily use
> arithmetic to calculate the offsets in your external flash memory.
how?

thanks



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux