29 # include <system_error>
52 [[nodiscard]]
auto make_last_error_string() -> std::string
54 const auto code = std::error_code{GetLastError(), std::system_category()};
55 return code.message();
71 auto handle = LoadLibrary(path);
75 throw std::runtime_error{make_last_error_string()};
91 template<
typename Sig>
96 ptr =
reinterpret_cast<Sig
>(GetProcAddress(handle, name));
98 throw std::runtime_error{make_last_error_string()};
113 if(handle ==
nullptr)
116 auto err = FreeLibrary(handle);
119 auto errstr = make_last_error_string();
121 std::fprintf(stderr,
"WARNING: Error while closing plugin library: %s\n", errstr.c_str());
123 std::fprintf(stderr,
"WARNING: Unknown error while closing plugin library.\n");