summaryrefslogtreecommitdiff
path: root/libtcc-test.c
blob: eae8e97f38a1aa1e8034c47a2f20d54a4f2d06ac (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
#include <libtcc.h>
#include <stdint.h>
#include <stdio.h>

const char *files[] = {
	"test.c",
	"test2.c",
	NULL
};

int main(int argc, char **argv) {
	TCCState *s = tcc_new();
	int (*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");

	int ret = start();

	return 0;
}