diff --git a/lib/Interpreter/Paths.cpp b/lib/Interpreter/Paths.cpp index e0e2762f2..367592a06 100644 --- a/lib/Interpreter/Paths.cpp +++ b/lib/Interpreter/Paths.cpp @@ -108,15 +108,15 @@ namespace platform { #if defined(_WIN32) void* DLOpen(const std::string& Path, std::string& Err /* = nullptr */) { - auto lib = llvm::sys::DynamicLibrary::getLibrary(Path.c_str(), Err); + auto lib = llvm::sys::DynamicLibrary::getLibrary(Path.c_str(), &Err); return lib.getOSSpecificHandle(); } void DLClose(void* Lib, std::string& Err /* = nullptr*/) { auto dl = llvm::sys::DynamicLibrary(Lib); llvm::sys::DynamicLibrary::closeLibrary(dl); - if (Err) { - *Err = std::string(); + if (Err.empty()) { + Err = std::string(); } } #else diff --git a/unittests/CppInterOp/DynamicLibraryManagerTest.cpp b/unittests/CppInterOp/DynamicLibraryManagerTest.cpp index cf48e052a..705c36ccb 100644 --- a/unittests/CppInterOp/DynamicLibraryManagerTest.cpp +++ b/unittests/CppInterOp/DynamicLibraryManagerTest.cpp @@ -57,6 +57,7 @@ TEST(DynamicLibraryManagerTest, Sanity) { // EXPECT_FALSE(Cpp::GetFunctionAddress("ret_zero")); } +#if defined(CPPINTEROP_UTILS_PATHS_H) TEST(UtilsPlatform, DLTest) { std::string err = ""; #ifdef __APPLE__ @@ -71,3 +72,4 @@ TEST(UtilsPlatform, DLTest) { #endif (void)dlopen_handle; } +#endif