General gcc4.0 porting guide

Hans de Goede j.w.r.degoede at hhs.nl
Fri Apr 29 12:15:15 UTC 2005



Nils Philippsen wrote:
> On Fri, 2005-04-29 at 13:56 +0200, Ralf Ertzinger wrote:
> 
>>Hi.
>>
>>Is there a general document showing common pitfalls when compiling a
>>package with gcc4.0 (and how to resolve them)?
>>
>>For example, what is the "right" way to deal with this:
>>
>>int* foo;
>>
>>[...]
>>((short int*)foo)++;  // gcc4 does not like this.
> 
> 
> 1) Fix the code in question (why is there a cast to short) ;-)
> 
> 2) perhaps:
> 
>   *foo = ((short int) (*foo)) + 1;

No, the original code moved the ptr your code instead changes the 
contents of what is pointed to.

Correct would be:
foo = (int *)((short int *)foo + 1);

Regards,

Hans




More information about the fedora-extras-list mailing list