From: Alan Chen Date: 2002-01-05T09:27:28+09:00 Subject: [ruby-talk:30251] Re: cdecl vs stdcall On Sat, Jan 05, 2002 at 04:37:52AM +0900, Shan-leung Maverick WOO wrote: > On Sat, 5 Jan 2002, Yukihiro Matsumoto wrote: > > > Could you tell me what stdcall is, and what I should do to switch? > > I quote MS's documentation here: > > A __stdcall function's arguments are pushed onto the stack from right to > left, and the called function pops these arguments from the stack before > it returns. > > The catch with stdcall is that you cannot do varargs (at least not the > straightforward way). For those, you can declare them as cdecl. > > For switching, I can only tell the MS story here. There is a compiler > switch (/Gz) that says use stdcall by default and then there is some > (typically small) changes to the source code like: > > process.c:594: RETSIGTYPE (__cdecl *hfunc)_((int)), (__cdecl > *qfunc)_((int)), (__cdecl *ifunc)_((int)); > > I cannot estimate the work needed to get Ruby (1.6.6) to use stdcall > correctly. To make it compile, I changed roughly 30 lines of source code > but that won't be sufficient to make it run. It's actually much more > effort because of the different stack management and GC issues. (And hence > I resort to use a stub DLL for now and proposing this for consideration > for future Ruby major release.) > > -- > All the best, > Maverick Woo Generally, for cross-platform code, I've seen a macro used where the cdecl/stdcall occurs. The macro may evaluate to nothing on platforms which don't need to specify between cdecl's and stdcalls. -- alan