[llvm-commits] CVS: llvm/lib/System/Win32/DynamicLibrary.cpp

Reid Spencer reid at x10sys.com
Mon Nov 29 02:39:57 PST 2004



Changes in directory llvm/lib/System/Win32:

DynamicLibrary.cpp updated: 1.2 -> 1.3
---
Log message:

Implement the default constructor which causes the current program to be
opened as if it was a dynamic library so its symbols can be searched too.


---
Diffs of the changes:  (+10 -4)

Index: llvm/lib/System/Win32/DynamicLibrary.cpp
diff -u llvm/lib/System/Win32/DynamicLibrary.cpp:1.2 llvm/lib/System/Win32/DynamicLibrary.cpp:1.3
--- llvm/lib/System/Win32/DynamicLibrary.cpp:1.2	Sat Nov 20 17:30:55 2004
+++ llvm/lib/System/Win32/DynamicLibrary.cpp	Mon Nov 29 04:39:46 2004
@@ -22,15 +22,21 @@
 //===          and must not be UNIX code
 //===----------------------------------------------------------------------===//
 
+DynamicLibrary::DynamicLibrary() : handle(0) {
+  handle = new HMODULE;
+  *((HMODULE*)handle) = GetModuleHandle(NULL);
+  
+  if (*((HMODULE*)handle) == 0) {
+    ThrowError("Can't GetModuleHandle: ");
+  }
+}
+
 DynamicLibrary::DynamicLibrary(const char*filename) : handle(0) {
   handle = new HMODULE;
   *((HMODULE*)handle) = LoadLibrary(filename);
 
   if (*((HMODULE*)handle) == 0) {
-    char Buffer[100];
-    // FIXME: This should use FormatMessage
-    sprintf(Buffer, "Windows error code %d\n", GetLastError());
-    throw std::string(Buffer);
+    ThrowError("Can't LoadLibrary: ");
   }
 }
 






More information about the llvm-commits mailing list