Using prototypes to avoid debugging problems

You can avoid complex debugging problems by ensuring that all functions are prototyped.

The C language provides a default prototype. If a function is not prototyped, it defaults to a function which returns an integer and has no information about the parameters.

The C++ language does not provide a default and always requires a prototype. However, C++ has an implicit integer return type extension for legacy code.

A common problem is that the default return type of int might not remain the same size as an associated pointer. For example, the function malloc() can cause truncation when an unprototyped function returns a pointer. This is because an unprototyped function is assumed to return an int (4 bytes).