[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] libtcc using existing structs

From: Joel Bodenmann
Subject: [Tinycc-devel] libtcc using existing structs
Date: Sun, 6 Nov 2016 17:23:14 +0100

Hello folks,

I am successfully using libtcc to compile & link single C functions
on-the-fly. Everything works great for those small C functions which don't
do anything other than calling other functions which are already part of the
program that uses libtcc. I simply use tcc_add_symbol() to make those
functions become available to the compiled function.
However, now I am facing issues when I try to compile C code that creates an
instance of a struct. For example, I try to compile a C program that creates
an instance of a struct named foo:

        struct foo f;

the struct "foo" is part of the already compiled program (the program that
uses libtcc to compile that smaller C program). The problem is that
compiling using tcc_compile_string() fails with the error message: "error:
unknown type size" at exactly that line. I understand that the compiler has
to know the declaration of the struct foo in order to work with it, however,
I fail to understand how I give TCC access to that struct declaration? I
tried using supplying the header file that contains the declaration of the
struct foo to TCC using tcc_add_file() but that didn't change anything at

I'm a bit lost at this point and I'd be thankful for any kind of help.
Please excuse if I am using wrong terminology somewhere.

Best regards,
~ Joel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]