mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-01 23:30:40 -08:00
New function for Windows system errors (M. Goffioul)
This commit is contained in:
parent
839db52d2f
commit
94ba2a064f
2 changed files with 30 additions and 0 deletions
|
|
@ -20,6 +20,9 @@
|
|||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
cs_overflow(void)
|
||||
|
|
@ -258,6 +261,30 @@ FElibc_error(const char *msg, int narg, ...)
|
|||
make_constant_string(strerror(errno)));
|
||||
}
|
||||
|
||||
#if defined(mingw32) || defined(_MSC_VER)
|
||||
void
|
||||
FEwin32_error(const char *msg, int narg, ...)
|
||||
{
|
||||
cl_va_list args;
|
||||
cl_object rest, win_msg_obj;
|
||||
char *win_msg;
|
||||
|
||||
cl_va_start(args, narg, narg, 0);
|
||||
rest = cl_grab_rest_args(args);
|
||||
|
||||
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||
0, GetLastError(), 0, (void*)&win_msg, 0, NULL) == 0)
|
||||
win_msg_obj = make_simple_string("[Unable to get error message]");
|
||||
else {
|
||||
win_msg_obj = make_string_copy(win_msg);
|
||||
LocalFree(win_msg);
|
||||
}
|
||||
|
||||
FEerror("~?~%Explanation: ~A.", 3, make_constant_string(msg), rest,
|
||||
win_msg_obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************
|
||||
* Higher level interface to errors *
|
||||
************************************/
|
||||
|
|
|
|||
|
|
@ -452,6 +452,9 @@ extern cl_object CEerror(const char *err_str, int narg, ...);
|
|||
extern void illegal_index(cl_object x, cl_object i);
|
||||
extern void FEtype_error_symbol(cl_object obj) /*__attribute__((noreturn))*/;
|
||||
extern void FElibc_error(const char *msg, int narg, ...) /*__attribute__((noreturn))*/;
|
||||
#if defined(mingw32) || defined(_MSC_VER)
|
||||
extern void FEwin32_error(const char *msg, int narg, ...) /*__attribute__((noreturn))*/;
|
||||
#endif
|
||||
|
||||
/* eval.c */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue