GCC: the impressive and the disappointing
blog.reverberate.org
blog.reverberate.org
I'm so sure it's valid not because I've actually read the C standard, but because the whole Win16 API was called this way, and Win32 uses a slight variation that passes more things in registers.
Further reading:
http://blogs.msdn.com/b/oldnewthing/archive/2004/01/02/47184... http://en.wikipedia.org/wiki/X86_calling_conventions http://unixwiz.net/techtips/win32-callconv.html http://webster.cs.ucr.edu/Page_win32/IczelionTuts/tut1.html
"If the expression that denotes the called function has a type that does not include a prototype, the integer promotions are performed on each argument, and arguments that have type float are promoted to double. These are called the default argument promotions. If the number of arguments does not equal the number of parameters, the behavior is undefined."
I take the last sentence to mean that an unprototyped function pointer may only be used to call a function that takes zero parameters.
Obviously if you don't pass the right number of parameters, the function behavior is undefined (i.e. a pascal function will of course muck up the stack)