Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not compile with tcc 0.9.27 #109

Open
evolbug opened this issue May 24, 2017 · 8 comments
Open

Does not compile with tcc 0.9.27 #109

evolbug opened this issue May 24, 2017 · 8 comments

Comments

@evolbug
Copy link

evolbug commented May 24, 2017

Cannot compile either v2.0.3 and v2.1.0 with the latest tcc version from http://repo.or.cz/tinycc.git mob branch.

tcc src/Table.c -c -I ./include -std=gnu99 -Wall -Wno-unused -g -ggdb -fdollars-in-identifiers -fPIC -DCELLO_NSTRACE -o obj/Table.o
src/Table.c:156: error: cannot cast 'struct Tuple' to 'void **'
make: *** [Makefile:125: obj/Table.o] Error 1

However, this page http://libcello.org/learn/best-improvements-of-cello-2.0 under Portability mentions that it can indeed be done

[..] Cello can be compiled easily with all of the major compilers including gcc, clang, cl.exe, and tcc (on the development branch).

Has anything changed since or has tcc not been tested?

@orangeduck
Copy link
Owner

Just not tested recently. I guess some aspect of tcc has changed. It isn't immediately obvious why tcc is throwing that error so I'll have to dig a little deeper to see exactly what is going on.

@Pebaz
Copy link

Pebaz commented Jan 4, 2019

Would love to see this fixed. I am creating a project that needs to bundle TCC and use Cello. I don't want to have to rely on the system compiler for each platform.

Attempted hello world example using TCC and failed:

tcc -fdollars-in-identifiers -I. example.c -L. -lCello -DCELLO_NSTRACE
#define CELLO_NSTRACE
#include "Cello.h"

int main(int argc, char** argv)
{
	print("ASDF\n");
	return 0;
}

Compiles with GCC just fine but throws this error when used with TCC:

example.c:6: error: cannot cast 'struct Tuple' to 'void **'

I could be wrong, but I believe it is referring to the string being passed to the print function inside the tuple of arguments.

Also, just discovered this project and I think it is amazing! Keep up the good work!

@orangeduck
Copy link
Owner

Thanks I'll try to find some time to work out what has changed. Looks like it might be something in the macros used for variable argument functions...

@Pebaz
Copy link

Pebaz commented Jan 12, 2019

Have you had a chance to look into this? =)

@orangeduck
Copy link
Owner

orangeduck commented Jan 16, 2019

I took a look. For some reason tcc is expanding macro arguments not really as expected. For example if I do:

var x = new(String);

Then it will throw that error, however if I do this:

var x = new_with(String, tuple());

It works fine...

However the definition of new is pretty much exactly that:

#define new(T, ...) ((struct T*)new_with(T, tuple(__VA_ARGS__)))

Even if you remove all the other stuff you still get the same error:

#define new(T, ...) new_with(T, tuple(__VA_ARGS__))

It seems to be failing to expand tuple(__VA_ARGS__) properly into tuple() when no arguments are passed to these variable argument macros.

Here I am not sure exactly what to do - I tried all my normal preprocessor hacks to try and get it to expand differently but I couldn't find anything that works. Maybe it is worth reporting a bug with tcc and/or to try and dig into the source code to try and fix it?

Either way I have a feeling this is not Cello related and the same issue might exist in normal C programs compiled with tcc. I hope that helps!

Dan

@Pebaz
Copy link

Pebaz commented Jan 16, 2019

Thank you very much for taking time out of your day to address this. I really appreciate it! Although the new() macro is nice, I will work with new_with() using an empty tuple for now until I can address this issue with TCC.

Thank you for narrowing this down and for creating such an ingenious project!

@KaruroChori
Copy link

Just a quick update for those interested in this issue in 2024. Many distributions are still delivering an older version of tcc which is incompatible. However the latest dev branch from https://repo.or.cz/tinycc.git seems to be working fine.

@pierrotstudio1
Copy link

pierrotstudio1 commented Nov 6, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants