defining big types on avr-gcc
Massimiliano Cialdi
massimiliano.cialdi@powersoft.it
Wed Aug 4 09:16:00 GMT 2010
Il giorno mer, 04/08/2010 alle 10.06 +0100, Andrew Haley ha scritto:
> > So why if I write:
> > big_dummy_t *p = (big_dummy_t*)0;
> > uint16_t p = (uint16_t)&(p->singledata);
> >
> > I get NO warning?
>
> Because the first is constant folded, the second isn't. Not that it
> matters, because your program is undefined anyway, since you're
> dereferencing a null pointer.
I never read or write data poined by p. I only use it to calculate
offset of fields inside it.
I could write:
uint16_t p = (uint16_t)((char *)&(p->singledata) - (char*)0);
thanks
More information about the Gcc-help
mailing list