Every time you call a function, there is an associated
calling convention and a
function stack frame (also know as an
activation record).
Both are machine, compiler, and language-dependent. The caller and the callee must agree on which arrangement to use before any transaction can occur. Mix any of it up and failure results or can result.
In this case, the default calling convention for C is
cdecl, meaning that the caller pushes the function arguments onto the stack, calls the function, and after the function returns the caller cleans-up the stack to its previous state.
The caller thinks that it is calling a function taking no arguments and returning nothing.
The callee thinks that there should be an
int sitting on the stack, and that it should return a pointer.
That's a whole can of worms just waiting to break out of the Peanut Brittle.
Here's more reading for you.
Wikipedia stuff :-J
http://en.wikipedia.org/wiki/Calling_convention
http://en.wikipedia.org/wiki/Call_stack
The Old New Thing: What can go wrong when you mismatch the calling convention?
http://blogs.msdn.com/oldnewthing/archive/2004/01/15/58973.aspx
http://blogs.msdn.com/oldnewthing/archive/2004/01/16/59415.aspx
Well, that's enough fun for now...
Enjoy. :-]