diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-11-20 23:30:55 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-11-20 23:30:55 +0000 |
commit | 7a4538941af7e5eb2b00e0b7c25cb34be548bcf5 (patch) | |
tree | 6f97da0e121fe9b13aed0ac302779f4ef56ff289 | |
parent | b95cbee93077979052e10771031ec209dd24294e (diff) | |
download | external_llvm-7a4538941af7e5eb2b00e0b7c25cb34be548bcf5.zip external_llvm-7a4538941af7e5eb2b00e0b7c25cb34be548bcf5.tar.gz external_llvm-7a4538941af7e5eb2b00e0b7c25cb34be548bcf5.tar.bz2 |
Cast the void* handle data member to HMODULE* to keep the VC++ compiler
happy. Thanks to Henrik Bach for pointing this out.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18056 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/System/Win32/DynamicLibrary.cpp | 14 | ||||
-rw-r--r-- | lib/System/Win32/DynamicLibrary.inc | 14 |
2 files changed, 18 insertions, 10 deletions
diff --git a/lib/System/Win32/DynamicLibrary.cpp b/lib/System/Win32/DynamicLibrary.cpp index 15730d4..b2add2f 100644 --- a/lib/System/Win32/DynamicLibrary.cpp +++ b/lib/System/Win32/DynamicLibrary.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "Win32.h" +#include <windef.h> namespace llvm { using namespace sys; @@ -22,9 +23,10 @@ using namespace sys; //===----------------------------------------------------------------------===// DynamicLibrary::DynamicLibrary(const char*filename) : handle(0) { - handle = LoadLibrary(filename); + handle = new HMODULE; + *((HMODULE*)handle) = LoadLibrary(filename); - if (handle == 0) { + if (*((HMODULE*)handle) == 0) { char Buffer[100]; // FIXME: This should use FormatMessage sprintf(Buffer, "Windows error code %d\n", GetLastError()); @@ -33,13 +35,15 @@ DynamicLibrary::DynamicLibrary(const char*filename) : handle(0) { } DynamicLibrary::~DynamicLibrary() { - if (handle) - FreeLibrary(handle); + assert(handle !=0 && "Invalid DynamicLibrary handle"); + if (*((HMODULE*)handle)) + FreeLibrary(*((HMODULE*)handle)); + delete (HMODULE*)handle; } void *DynamicLibrary::GetAddressOfSymbol(const char *symbolName) { assert(handle !=0 && "Invalid DynamicLibrary handle"); - return GetProcAddress(handle, symbolName); + return (void*) GetProcAddress(*((HMODULE*)handle), symbolName); } } diff --git a/lib/System/Win32/DynamicLibrary.inc b/lib/System/Win32/DynamicLibrary.inc index 15730d4..b2add2f 100644 --- a/lib/System/Win32/DynamicLibrary.inc +++ b/lib/System/Win32/DynamicLibrary.inc @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "Win32.h" +#include <windef.h> namespace llvm { using namespace sys; @@ -22,9 +23,10 @@ using namespace sys; //===----------------------------------------------------------------------===// DynamicLibrary::DynamicLibrary(const char*filename) : handle(0) { - handle = LoadLibrary(filename); + handle = new HMODULE; + *((HMODULE*)handle) = LoadLibrary(filename); - if (handle == 0) { + if (*((HMODULE*)handle) == 0) { char Buffer[100]; // FIXME: This should use FormatMessage sprintf(Buffer, "Windows error code %d\n", GetLastError()); @@ -33,13 +35,15 @@ DynamicLibrary::DynamicLibrary(const char*filename) : handle(0) { } DynamicLibrary::~DynamicLibrary() { - if (handle) - FreeLibrary(handle); + assert(handle !=0 && "Invalid DynamicLibrary handle"); + if (*((HMODULE*)handle)) + FreeLibrary(*((HMODULE*)handle)); + delete (HMODULE*)handle; } void *DynamicLibrary::GetAddressOfSymbol(const char *symbolName) { assert(handle !=0 && "Invalid DynamicLibrary handle"); - return GetProcAddress(handle, symbolName); + return (void*) GetProcAddress(*((HMODULE*)handle), symbolName); } } |