tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Issue compiling Lua


From: Rob Landley
Subject: Re: [Tinycc-devel] Issue compiling Lua
Date: Thu, 3 May 2007 13:20:32 -0400
User-agent: KMail/1.9.1

On Thursday 03 May 2007 12:50 pm, address@hidden wrote:
> I was trying to compile Lua in TCC, and it gave me this error:
> 
> ldo.c:495: function pointer expected

Could you try the version at "http://landley.net/hg/tinycc"; and see if that's 
got the right fixes?  You can get a tarball of the current version from the 
web interface via the link up top:
  http://landley.net/hg/tinycc?ca=tip;type=gz

> That line is:
> 
> tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z,
> &p->buff, p->name);
> 
> I turned this into an if statement to make it compile:
> 
> if (c == LUA_SIGNATURE[0])
>  tf = luaU_undump(L, p->z, &p->buff, p->name);
> else
>  tf = luaY_parser(L, p_>z, &p->buff, p->name);
> 
> This worked, but I was wondering if we could make the first way
> compile. Supposedly it's valid ANSI C, because that's the standard
> followed by Lua.

This might be one of the fixes from the grisckha mega-patch that David 
Wheeler's been so nicely breaking up for us.

http://www.dwheeler.com/trusting-trust/grischka-todo.txt

Looks like it might be case_1, actually.  Let's see, cutting and pasting from 
that to put together a possible patch, it looks like this:

diff -uwr --exclude tccpe.c ../tcc-cvs/tinycc/tinycc/tcc.c ./tcc.c
--- ../tcc-cvs/tinycc/tinycc/tcc.c
+++ ./tcc.c
@@ -7771,6 +7823,9 @@
             } else if (bt1 == VT_STRUCT || bt2 == VT_STRUCT) {
                 /* XXX: test structure compatibility */
                 type = type1;
+            } else if (bt1 == VT_FUNC || bt2 == VT_FUNC) { //gr case_1.2
+                /* XXX: test function compatibility */
+                type = type1;
             } else if (bt1 == VT_VOID || bt2 == VT_VOID) {
                 /* NOTE: as an extension, we accept void on only one side */
                 type.t = VT_VOID;
@@ -7785,6 +7840,8 @@
                 
             /* now we convert second operand */
             gen_cast(&type);
+            if (VT_STRUCT == (vtop->type.t & VT_BTYPE))
+                gaddrof(); //gr case_1.1
             rc = RC_INT;
             if (is_float(type.t)) {
                 rc = RC_FLOAT;
@@ -7802,6 +7859,8 @@
             /* put again first value and cast it */
             *vtop = sv;
             gen_cast(&type);
+            if (VT_STRUCT == (vtop->type.t & VT_BTYPE))
+                gaddrof(); //gr case_1.1
             r1 = gv(rc);
             move_reg(r2, r1);
             vtop->r = r2;

Might fix it?

Rob




reply via email to

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