Given that tcc_add_library() takes a TCCState it seems to me
that a call shouldn't persist to subsequent TCCStates.
This example seems to show that it does.
$ tcc -version
tcc version 0.9.28rc 2024-06-11 mob@08a4c52d (AArch64 Linux)
$ tcc tcc-add-library-bug.c -ltcc && ./a.out
tcc_add_library=0
tcc: error: undefined symbol 'atan'
tcc_add_library=1
3.14159
tcc_add_library=0
3.14159
Thanks - Eric
#include <stdio.h>#include "libtcc.h"char *C = "#include
<math.h>\n" "#include <stdio.h>\n" "void pi() {
printf(\"%g\\n\", 4 * atan(1)); }\n";void test(int add_lib){
TCCState *s = tcc_new(); tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
printf("tcc_add_library=%d\n", add_lib); if (add_lib)
tcc_add_library(s, "m"); if (!tcc_compile_string(s, C) &&
!tcc_relocate(s)) { void (*pi)() = tcc_get_symbol(s, "pi");
pi(); } tcc_delete(s); printf("\n");}int main(){
test(0); test(1); test(0); return 0;}
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel