[Top][All Lists]

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

Re: [Tinycc-devel] libtcc using existing structs

From: David Mertens
Subject: Re: [Tinycc-devel] libtcc using existing structs
Date: Sun, 27 Nov 2016 07:09:07 -0500

Hello Joel,

tcc_add_file() probably won't work for what you're trying to use it for. The simplest way I can think to fix this problem is to #include the file that contains the struct declaration.

Hope that helps!

On Sun, Nov 6, 2016 at 11:23 AM, Joel Bodenmann <address@hidden> wrote:
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

Tinycc-devel mailing list

 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan

reply via email to

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