From ec3f97394f0629ddc423ac7962b9cfa126c61662 Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Thu, 20 Jun 2024 02:25:54 +0900 Subject: Improve error handling --- src/disp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/disp.c b/src/disp.c index f3448ae..6710f40 100644 --- a/src/disp.c +++ b/src/disp.c @@ -18,12 +18,13 @@ #include #include +#include #include #include #include "disp.h" -#define dlsym_and_check(dest, name) \ +#define dlsym_and_check(dest, name) \ dest->name = dlsym(dest->dl_handle, #name); \ if (!dest->name) { \ dlclose(dest->dl_handle); \ @@ -43,7 +44,11 @@ get_disp(char *disp_name) void *handle = dlopen(so_path, RTLD_LAZY); if (!handle) - return NULL; + { + char *msg = dlerror(); + fprintf(stderr, "calculer: %s\n", msg); + exit(1); + } struct disp *disp = malloc(sizeof(*disp)); disp->dl_handle = handle; -- cgit v1.2.3