General gcc4.0 porting guide

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



Miloslav Trmac wrote:
> On Fri, Apr 29, 2005 at 01:56:04PM +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)?
> 
> There are change descriptions on gcc.gnu.org.
> 
> 
>>For example, what is the "right" way to deal with this:
>>
>>int* foo;
>>
>>[...]
>>((short int*)foo)++;  // gcc4 does not like this.
> 
> foo = (short int *)(foo + 1);
> 	Mirek

Wrong (again) people please don't try to help unless you know how 
pointer arithmetic works in C. foo is a int *, so your assignment will 
give an invalid ptr type warning if not an error. also since you first 
increment foo and then cast it foo will be increased by 4 (sizeof(int) 
== 4) where the original code increased it by 2.

Regards,

Hans




More information about the fedora-extras-list mailing list