-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhot_reload.c
More file actions
39 lines (31 loc) · 1.05 KB
/
hot_reload.c
File metadata and controls
39 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include <stdbool.h>
#include <raylib.h>
#include <dlfcn.h>
#include "hot_reload.h"
void *libplug = NULL;
static const char *plug_file_name = "libplug.so";
#define PLUG(name, ...) name##_t *name = NULL;
PLUG_FUNCS
#undef PLUG
bool reload_plug(void)
{
if (libplug != NULL)
dlclose(libplug);
libplug = dlopen(plug_file_name, RTLD_NOW);
if (libplug == NULL)
{
TraceLog(LOG_ERROR, "Could not load %s: %s\n", plug_file_name, dlerror());
return false;
}
#define PLUG(name, ...) \
name = dlsym(libplug, #name); \
if (name == NULL) \
{ \
printf("Could not find symbol %s for %s: %s\n", #name, plug_file_name, dlerror()); \
return false; \
}
PLUG_FUNCS
#undef PLUG
return true;
}