Assigning pointers

In 64-bit mode, pointers and int types are no longer the same size. The implications of this are:

Although code constructs such as the following are valid in 32-bit mode:

a=(char*) calloc(25);

Without a function prototype for calloc, when the same code is compiled in 64-bit mode, the compiler assumes the function returns an int, so a is silently truncated, and then sign-extended. Type casting the result will not prevent the truncation, as the address of the memory allocated by calloc was already truncated during the return. In this example, the correct solution would be to include the header file, stdlib.h, which contains the prototype for calloc.

To avoid these types of problems: