tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] TinyCC


From: grischka
Subject: Re: [Tinycc-devel] TinyCC
Date: Sat, 02 Aug 2014 20:07:18 +0200
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Please use the tinycc mailing list.

Gonzo FWS wrote:
Hey,
I'm not much of an expert on the C-standard, however I have been using libtcc in a C++11 project of mine.
I cannot immediately use these functions:
tcc_get_symbol
tcc_add_symbol

Because C++ is very strict: It will not convert void* to any function pointer and even vice versa.

How not?

    void (*pfoo)() = (void(*)()) tcc_get_symbol(s, "foo");

Is tcc_get_symbol and tcc_add_symbol used for non-functions, eg. int? Or strictly for functions?

If they are only ever used for functions, this solution may work for everyone:
typedef void (*tcc_func_ptr)();
LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const tcc_func_ptr val);
LIBTCCAPI tcc_func_ptr tcc_get_symbol(TCCState *s, const char *name);

As I see it that is not better for C++, but worse for C.

It works because C++ allows conversion between all types of function pointers.
In any case, it is a matter of pedantry as far as strictly C goes.
I have to continue to use my variation for it to compile, and it's working well.



A super-minor nitpick I have is that I cannot recompile code using the same code-generation state. (tcc_state_new) If it's only less efficient in my case because my libpaths and incpaths never change, as well as the linker symbols I add. I have no specific wishes regarding this, but if you have any plans to make it possible to clear out all the code (reset) and compile again with all or some of the settings intact, that would be super.

Sure, everybody has extra wishes, and except for that then wants
an interface as simple as possible in order not to have too much
to read. ;)

Thanks for all the great work being done, as it's a very interesting project.

Thanks,

-- gr

-gonzo





reply via email to

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