From 910df6227d9a02c6984502b5cc2cb54154f8e8dd Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 20 Sep 2023 00:41:29 +0800 Subject: improve strerror --- core/src/xmake/os/strerror.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'core/src') 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 +#else # include # include #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 -- cgit v1.3.1