blob: 047ba8ab67a1d7f6d10866c69010de8161c92f65 (
plain)
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
|
#include "script_sys.h"
#include <libtcc.h>
#include <stddef.h>
#include <stdio.h>
TCCState* state = NULL;
int goob(void)
{
return 255;
}
void init_script_sys(void)
{
state = tcc_new();
tcc_set_output_type(state, TCC_OUTPUT_MEMORY);
tcc_add_symbol(state, "goob", goob);
tcc_add_file(state, "assets/src/main.c");
tcc_relocate(state, TCC_RELOCATE_AUTO);
int(*const test)() = tcc_get_symbol(state, "test");
printf("Result: %i\n", test());
}
void deinit_script_sys(void)
{
tcc_delete(state);
state = NULL;
}
|