From 308d2fcfc4d19b0e97a1fe78249bfa43ae4fe0bd Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Wed, 26 May 2021 11:11:42 -0400 Subject: Added libtcc-test.c --- libtcc-test.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 libtcc-test.c diff --git a/libtcc-test.c b/libtcc-test.c new file mode 100644 index 0000000..472ad68 --- /dev/null +++ b/libtcc-test.c @@ -0,0 +1,29 @@ +#include +#include +#include + +const char *files[] = { + "test.c", + "test2.c", + NULL +}; + +int main(int argc, char **argv) { + TCCState *s = tcc_new(); + void (*start)(void); + + tcc_set_output_type(s, TCC_OUTPUT_MEMORY); + + for (int i = 0; files[i]; i++) { + if (tcc_add_file(s, files[i])) { + printf("oof, press f, failed to compile %s.\n", files[i]); + return 1; + } + } + + start = tcc_get_symbol(s, "start"); + + start(); + + return 0; +} -- cgit v1.2.3-13-gbd6f