Ticket #4422: dlerr.win.2.patch
File dlerr.win.2.patch, 1.3 KB (added by , 16 years ago) |
---|
-
libs/libmyth/compat.h
17 17 #include <ws2tcpip.h> 18 18 #define setsockopt(a, b, c, d, e) setsockopt(a, b, c, (const char*)(d), e) 19 19 #undef close 20 #include <stdio.h> // for snprintf(), used by inline dlerror() 20 21 #else 21 22 #include <sys/time.h> // Mac OS X needs this before sys/resource 22 23 #include <sys/resource.h> // for setpriority … … 189 190 #define dlopen(x, y) LoadLibraryA((x)) 190 191 #define dlclose(x) !FreeLibrary((HMODULE)(x)) 191 192 #define dlsym(x, y) GetProcAddress((HMODULE)(x), (y)) 192 #define dlerror GetLastError 193 // 194 //#define dlerror() "" 195 inline const char *dlerror(void) 196 { 197 #define DLERR_MAX 512 198 static char errStr[DLERR_MAX]; 199 DWORD errCode = GetLastError(); 200 201 if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | 202 FORMAT_MESSAGE_IGNORE_INSERTS | 203 FORMAT_MESSAGE_MAX_WIDTH_MASK, 204 NULL, errCode, 205 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 206 errStr, DLERR_MAX - 1, NULL)) 207 snprintf(errStr, DLERR_MAX - 1, 208 "dlopen()/dlsym() caused error %d", errCode); 209 210 return errStr; 211 } 193 212 #endif // USING_MINGW 194 213 195 214 #ifdef USING_MINGW