Pedro Alves wrote: > Can't see how that can run fine? The compiler will set up the call > assuming cdecl convention, while the called function has stdcall > convention.
I would expect the 'reinterpret_cast<type>(::getaddrinfo)' to fix that. With this little example: #include <config.h> #include <netdb.h> int main (void) { struct addrinfo *res; gnulib_::getaddrinfo ("www.google.com", "http", NULL, &res); return (0); } A dis-assembly shows: .rdata, "dr2" ?getaddrinfo@gnulib_@@3U_gl_getaddrinfo_wrapper@1@B: 00 00 00 00 $SG37638: "http" $SG37639: "www.google.com" .text, "crx4" _main: push ebp mov ebp,esp push ecx lea eax,-0x4[ebp] push eax push 0x00000000 push $SG37638 push $SG37639 mov ecx,?getaddrinfo@gnulib_@@3U_gl_getaddrinfo_wrapper@1@B call ??B_gl_getaddrinfo_wrapper@gnulib_@@QBEP6AHPBD0PBUaddrinfo@@PAPAU2@@ZXZ call eax add esp,0x00000010 xor eax,eax mov esp,ebp pop ebp ret ??B_gl_getaddrinfo_wrapper@gnulib_@@QBEP6AHPBD0PBUaddrinfo@@PAPAU2@@ZXZ: push ebp mov ebp,esp push ecx mov dword ptr -0x4[ebp],ecx mov eax,dword ptr __imp__getaddrinfo@16 mov esp,ebp pop ebp ret Running the program shows that '__imp__getaddrinfo@16' gets the arguments in the right order. So '__stdcall' must be in effect. > Are all MSVC C run time functions __stdcall, or just a few? > It's been a long while since I used MSVC. getaddrinfo() etc. is not a 'run time function' but a SDK functions. Almost all functions in the Windows SDK are __stdcall. The runtime functions are __cdecl. -- --gv