"BartC" <> wrote in message
news:ku7Bs.322256$4...
> "glen herrmannsfeldt" <> wrote in message
> news:kb2ubm$4oj$...
>> With the cdecl convention, you should be safe passing extra arguments
>> that are ignored by the callee. The standard doesn't say anything
>> about this, though.
>
> That's a good point. On my machine, calls to normal C functions have the
> stack adjusted by the caller. So the extra params are popped.
>
> But with C calls to Win32 functions, for example, this is handled by the
> callee, which will only pop what are expected.
Looking at the output of gcc under Windows, this seems to do the opposite of
what I expected:
Calls to normal C functions, have the stack adjusted by the callee.
Calls to Windows functions (__stdcall) have the stack adjusted by the
caller. Yet I can call the same functions from other languages, and I don't
need to do this!
Furthermore, when obtaining the address of a __stdcall function dynamically
(GetProcAddress), it seems to work just as well whether I declare the
function pointer as __stdcall or not. All very strange. Anyway it works at
the minute (based on my extensive tests of calling one function..).
(Example
#include <windows.h>
int main (void) {
int fnaddr;
fnaddr=(int)GetProcAddress(LoadLibrary("user32")," MessageBoxA");
if (fnaddr==0) exit(0);
((int __stdcall (*)(int,char*,char*,int))fnaddr) (0,"With
__stdcall","one",0);
((int (*)(int,char*,char*,int))fnaddr) (0,"Without __stdcall","two",0);
}
--
Bartc