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

Re: General gcc4.0 porting guide





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


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