diff options
Diffstat (limited to 'libtcc_test.c')
| -rw-r--r-- | libtcc_test.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/libtcc_test.c b/libtcc_test.c index 4c16902..d257a72 100644 --- a/libtcc_test.c +++ b/libtcc_test.c @@ -35,7 +35,6 @@ int main(int argc, char **argv) { TCCState *s; int (*func)(int); - unsigned long val; void *mem; int size; @@ -50,10 +49,9 @@ int main(int argc, char **argv) tcc_compile_string(s, my_program); - /* as a test, we add a symbol that the compiled program can be - linked with. You can have a similar result by opening a dll - with tcc_add_dll(() and using its symbols directly. */ - tcc_add_symbol(s, "add", (unsigned long)&add); + /* as a test, we add a symbol that the compiled program can use. + You may also open a dll with tcc_add_dll() and use symbols from that */ + tcc_add_symbol(s, "add", add); /* get needed size of the code */ size = tcc_relocate(s, NULL); @@ -65,8 +63,9 @@ int main(int argc, char **argv) tcc_relocate(s, mem); /* get entry symbol */ - tcc_get_symbol(s, &val, "foo"); - func = (void *)val; + func = tcc_get_symbol(s, "foo"); + if (!func) + return 1; /* delete the state */ tcc_delete(s); |
