Skip to content

Commit

Permalink
Fixed implementation of VariableDeclarationExpression::loadNativeFunc…
Browse files Browse the repository at this point in the history
…tion() for Windows target.
  • Loading branch information
nthnn committed Dec 13, 2024
1 parent fb45576 commit ec27a2c
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/n8/ast/expression/VariableDeclarationExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,11 @@ NativeFunction VariableDeclarationExpression::loadNativeFunction(
#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64)

std::filesystem::path path(library);
std::filesystem::path parentFolder = path.parent_path();
std::string parentFolder = path
.parent_path()
.string();

std::string parentPathFolder = parentFolder.string();
const char* parentPathStr = parentPathFolder.c_str();
int size = MultiByteToWideChar(
CP_UTF8, 0, parentPathStr, -1, NULL, 0
);

PWSTR searchPath = new wchar_t[(size_t) size];
if(searchPath)
MultiByteToWideChar(
CP_UTF8, 0,
parentPathStr,
-1, searchPath, size
);

AddDllDirectory(searchPath);
SetDllDirectoryW(parentFolder.c_str());
handle = LoadLibraryA(library.c_str());

#elif defined(__APPLE__)
Expand Down

0 comments on commit ec27a2c

Please sign in to comment.