summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2023-09-19 22:11:26 +0800
committerGitHub <[email protected]>2023-09-19 22:11:26 +0800
commitd6dc25ea6230005cbfe2ee4e7f5c1e47f01d1faa (patch)
tree4a723ae2b2219b203e7604afc91073293326dc25 /core/src
parent9a18551f7ef76f435283eec84e2e1b0edd87b0f5 (diff)
parent910df6227d9a02c6984502b5cc2cb54154f8e8dd (diff)
Merge pull request #4217 from xmake-io/error
improve strerror
Diffstat (limited to 'core/src')
-rw-r--r--core/src/xmake/os/strerror.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/src/xmake/os/strerror.c b/core/src/xmake/os/strerror.c
index 7f0b5e3bb..e4d3b7fa3 100644
--- a/core/src/xmake/os/strerror.c
+++ b/core/src/xmake/os/strerror.c
@@ -29,7 +29,9 @@
* includes
*/
#include "prefix.h"
-#if !defined(TB_CONFIG_OS_WINDOWS) || defined(TB_COMPILER_LIKE_UNIX)
+#if defined(TB_CONFIG_OS_WINDOWS) && !defined(TB_COMPILER_LIKE_UNIX)
+# include <windows.h>
+#else
# include <errno.h>
# include <string.h>
#endif
@@ -68,7 +70,9 @@ tb_int_t xm_os_strerror(lua_State* lua)
else
{
#if defined(TB_CONFIG_OS_WINDOWS) && !defined(TB_COMPILER_LIKE_UNIX)
- lua_pushstring(lua, "Unknown");
+ tb_char_t strerr[128] = {0};
+ tb_snprintf(strerr, sizeof(strerr), "Unknown Error (%lu)", (tb_size_t)GetLastError());
+ lua_pushstring(lua, strerr);
#else
lua_pushstring(lua, strerror(errno));
#endif