1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

Cast the void* handle data member to HMODULE* to keep the VC++ compiler

happy. Thanks to Henrik Bach for pointing this out.

llvm-svn: 18056
This commit is contained in:
Reid Spencer 2004-11-20 23:30:55 +00:00
parent 1805f32d5f
commit de847ecdaa

View File

@ -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);
}
}