Hi, On 09:59 PM, Jan Danielsson wrote: > On Unix systems, there's no need to take any special notice. On > Win32, however, one needs to be aware of potential problems with calling > conventions. > > I couldn't find any calling convention macros in OpenSSL's headers, > so I'm not entirely sure what calling convention to used for the > callback function. Some Random Post On The Internet stated that OpenSSL > simply sets __cdecl as the global default. I haven't checked this, but I > did look at the function prototypes, and they do not have explicit > calling conventions. > > I believe that the default calling convention for VC++ is __stdcall, > so everything is nicely laid out in a "this will come back to bite me" > way. :( No, the default for MSVC is __cdecl (http://msdn.microsoft.com/en-us/library/zkwh89ks.aspx), although the default for Win32 API functions is __stdcall.
To make the function accessible in the DLL, OpenSSL must be using a .DEF file or __declspec(dllexport). Either will cause __cdecl and __stdcall functions to be decorated differently. If you look at the DLL's export table (e.g. using 'dumpbin /exports' or Dependency Walker (http://www.dependencywalker.com/) ) then __cdecl calls will be decorated as _Function (or just Function, depending on the tool), while __stdcall will be decorated as _Function@n (for some number n). This link provides more info: http://www.willus.com/mingw/yongweiwu_stdcall.html . In other words if you use LoadLibraryEx() and can GetProcAddress() the function, it is almost certainly __cdecl. Other relevant links: - MSDN Blogs - Why can't I GetProcAddress a function I dllexport'ed? http://blogs.msdn.com/b/oldnewthing/archive/2004/01/12/57833.aspx - MSDN - Using __declspec(dllimport) and __declspec(dllexport) http://msdn.microsoft.com/en-us/library/aa271769(VS.60).aspx <http://msdn.microsoft.com/en-us/library/aa271769%28VS.60%29.aspx> - MSDN __stdcall http://msdn.microsoft.com/en-us/library/zxk0tw93(VS.71).aspx <http://msdn.microsoft.com/en-us/library/zxk0tw93%28VS.71%29.aspx> Regards, Twylite _______________________________________________ fossil-users mailing list [email protected] http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

