1.1 --- a/sourcemm/metamod_oslink.cpp Thu Jan 10 18:19:32 2008 +0000
1.2 +++ b/sourcemm/metamod_oslink.cpp Thu Jan 10 19:05:59 2008 +0000
1.3 @@ -27,19 +27,31 @@
1.4
1.5 #include "metamod_oslink.h"
1.6 #include <malloc.h>
1.7 +#include <stdio.h>
1.8 #ifdef __linux
1.9 #include <errno.h>
1.10 -#include <stdio.h>
1.11 #endif
1.12
1.13 #if defined __WIN32__ || defined _WIN32 || defined WIN32
1.14 const char *dlerror()
1.15 {
1.16 static char buf[1024];
1.17 - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
1.18 - NULL, GetLastError(),
1.19 - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
1.20 - (LPTSTR) &buf, 0, NULL);
1.21 + DWORD num;
1.22 +
1.23 + num = GetLastError();
1.24 +
1.25 + if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
1.26 + NULL,
1.27 + num,
1.28 + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
1.29 + buf,
1.30 + sizeof(buf),
1.31 + NULL)
1.32 + == 0)
1.33 + {
1.34 + _snprintf(buf, sizeof(buf), "unknown error %x", num);
1.35 + }
1.36 +
1.37 return buf;
1.38 }
1.39 #endif