Jelajahi Sumber

增加获取模块加载错误信息

xx 2 tahun lalu
induk
melakukan
11a2d5c0eb
1 mengubah file dengan 7 tambahan dan 1 penghapusan
  1. 7 1
      src/core/modulemanager.cpp

+ 7 - 1
src/core/modulemanager.cpp

@@ -33,6 +33,7 @@ fastweb::module_manager::~module_manager()
 }
 void fastweb::module_manager::start()
 {
+#ifdef _WIN32
 	auto get_last_error_desc = []()->std::string {
 		DWORD dwError = GetLastError();
 		// 获取错误描述  
@@ -51,6 +52,7 @@ void fastweb::module_manager::start()
 		// 输出错误描述  
 		return std::string(lpMsgBuf);
 	};
+#endif
 	close();
 	auto ms = modules();
 	for (size_t i = 0; i < ms.size(); i++)
@@ -62,7 +64,11 @@ void fastweb::module_manager::start()
 		mi.dll = LoadLibrary(mod_filepath.c_str());
 		if (mi.dll == nullptr)
 		{
-			LOG_ERROR("module loading failed, filename: " + mod_filepath+","+ codec::to_utf8(get_last_error_desc()));
+			LOG_ERROR("module loading failed, filename: " + mod_filepath
+#ifdef _WIN32
+				+","+ codec::to_utf8(get_last_error_desc())
+#endif
+			);
 			continue;
 		}
 		mi.func = (fastweb_module_regist)GetProcAddress((HMODULE)mi.dll, "fastweb_module_regist");