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

Re: General gcc4.0 porting guide



thias spam spam spam spam spam spam spam egg and spam freshrpms net (Matthias Saou) writes:

>> >>((short int*)foo)++;  // gcc4 does not like this.
>> ...
>> Correct would be:
>> foo = (int *)((short int *)foo + 1);
>
> Hmmm, so I guess the patch I've made for libmpeg3 is wrong. What would the
> proper fix for this be, then?
>
>       *((unsigned short*)data)++ = \
>                ((CLIP(r_l) & 0xf8) << 8) | \
>                ((CLIP(g_l) & 0xfc) << 3) | \
>                ((CLIP(b_l) & 0xf8) >> 3);

When this happens in a loop, I would write:

| uint16_t  *data_c = (uint16_t *)(data);
| 
| for (....) {
|     ...
|     *data_c++ = ((CLIP...));    // FIXME: what's about endianess?
| }
| 
| data = (uint32_t *)(data_c);    // FIXME: what's about aligment??


But it would be much better, to use a fitting datastructure for 'data'
instead of a plain uint32_t[]. But that's an upstream but not packager
task.




Enrico

Attachment: pgp00193.pgp
Description: PGP signature


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