Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
December 22, 2005 Interesting error | ||||
---|---|---|---|---|
| ||||
I'm trying to work with the lua D port at http://svn.dsource.org/projects/bindings/trunk/lua/ And I ran into an interesting error: "cannot implicitly convert expression (#luaopen_base) of type int(C *)(lua_State * L) to int(C *)(lua_State* L)" When compiling this code: ----------------------------------------------- import lua.lua; import lua.lualib; import lua.lauxlib; int main(char[][] args) { lauL_reg lr; lr.name = "base"; lr.func = &luaopen_base; return 0; } ----------------------------------------------- Anybody have any idea what's going on here? Bryan Ross daerid@gmail.com |
December 22, 2005 Re: Interesting error | ||||
---|---|---|---|---|
| ||||
Posted in reply to daerid | On Thu, 22 Dec 2005 10:11:03 +0000 (UTC), daerid <daerid@gmail.com> wrote:
> I'm trying to work with the lua D port at
> http://svn.dsource.org/projects/bindings/trunk/lua/
>
> And I ran into an interesting error:
>
> "cannot implicitly convert expression (#luaopen_base) of type
> int(C *)(lua_State * L) to int(C *)(lua_State* L)"
>
> When compiling this code:
>
> -----------------------------------------------
> import lua.lua;
> import lua.lualib;
> import lua.lauxlib;
>
> int main(char[][] args)
> {
> lauL_reg lr;
> lr.name = "base";
> lr.func = &luaopen_base;
> return 0;
> }
> -----------------------------------------------
>
> Anybody have any idea what's going on here?
Can you post the definition of "lauL_reg" and "luaopen_base". I've seen an error like this when the "extern" type was different, perhaps that is the case here?
Regan
|
December 22, 2005 Re: Interesting error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | Regan Heath wrote:
> On Thu, 22 Dec 2005 10:11:03 +0000 (UTC), daerid <daerid@gmail.com> wrote:
>
>> I'm trying to work with the lua D port at
>> http://svn.dsource.org/projects/bindings/trunk/lua/
>>
>> And I ran into an interesting error:
>>
>> "cannot implicitly convert expression (#luaopen_base) of type
>> int(C *)(lua_State * L) to int(C *)(lua_State* L)"
>>
>> When compiling this code:
>>
>> -----------------------------------------------
>> import lua.lua;
>> import lua.lualib;
>> import lua.lauxlib;
>>
>> int main(char[][] args)
>> {
>> lauL_reg lr;
>> lr.name = "base";
>> lr.func = &luaopen_base;
>> return 0;
>> }
>> -----------------------------------------------
>>
>> Anybody have any idea what's going on here?
>
>
> Can you post the definition of "lauL_reg" and "luaopen_base". I've seen an error like this when the "extern" type was different, perhaps that is the case here?
>
> Regan
extern (C) {
struct luaL_reg {
const char *name;
lua_CFunction func;
};
int luaopen_base (lua_State *L);
}
Both are extern(C). I'll play around and see if I can re-create that error in a little bit.
|
December 22, 2005 Re: Interesting error | ||||
---|---|---|---|---|
| ||||
Posted in reply to clayasaurus | On Thu, 22 Dec 2005 15:59:20 -0500, clayasaurus <clayasaurus@gmail.com> wrote: > Regan Heath wrote: >> On Thu, 22 Dec 2005 10:11:03 +0000 (UTC), daerid <daerid@gmail.com> wrote: >> >>> I'm trying to work with the lua D port at >>> http://svn.dsource.org/projects/bindings/trunk/lua/ >>> >>> And I ran into an interesting error: >>> >>> "cannot implicitly convert expression (#luaopen_base) of type >>> int(C *)(lua_State * L) to int(C *)(lua_State* L)" >>> >>> When compiling this code: >>> >>> ----------------------------------------------- >>> import lua.lua; >>> import lua.lualib; >>> import lua.lauxlib; >>> >>> int main(char[][] args) >>> { >>> lauL_reg lr; >>> lr.name = "base"; >>> lr.func = &luaopen_base; >>> return 0; >>> } >>> ----------------------------------------------- >>> >>> Anybody have any idea what's going on here? >> Can you post the definition of "lauL_reg" and "luaopen_base". I've seen an error like this when the "extern" type was different, perhaps that is the case here? >> Regan > > extern (C) { > > struct luaL_reg { > const char *name; > lua_CFunction func; > }; > > int luaopen_base (lua_State *L); > > } > > Both are extern(C). And what about "lua_CFunction" :) > I'll play around and see if I can re-create that error in a little bit. Ok. Regan |
December 22, 2005 Re: Interesting error | ||||
---|---|---|---|---|
| ||||
Posted in reply to daerid | The problem seemed to be that lua_CFunction was defined as
alias int (*lua_CFunction) (lua_State *L);
The fix is to use stronger typing like
typedef int (*lua_CFunction) (lua_State *L);
I just commited new changes to the trunk which fix this problem. Update to that version and tell me if you are having any more problems. Thanks.
~ Clay
daerid wrote:
> I'm trying to work with the lua D port at
> http://svn.dsource.org/projects/bindings/trunk/lua/
>
> And I ran into an interesting error:
>
> "cannot implicitly convert expression (#luaopen_base) of type int(C *)(lua_State * L) to int(C *)(lua_State* L)"
>
> When compiling this code:
>
> -----------------------------------------------
> import lua.lua;
> import lua.lualib;
> import lua.lauxlib;
>
> int main(char[][] args)
> {
> lauL_reg lr;
> lr.name = "base";
> lr.func = &luaopen_base;
> return 0;
> }
> -----------------------------------------------
>
> Anybody have any idea what's going on here?
>
> Bryan Ross
> daerid@gmail.com
|
December 22, 2005 Re: Interesting error | ||||
---|---|---|---|---|
| ||||
Posted in reply to clayasaurus | It would be nice if this error message was more descriptive. I've seen the same error occur when the calling convention was different i.e. different extern declarations, and now when the type was an alias instead of a typedef.
Regan
On Thu, 22 Dec 2005 16:46:31 -0500, clayasaurus <clayasaurus@gmail.com> wrote:
> The problem seemed to be that lua_CFunction was defined as
>
> alias int (*lua_CFunction) (lua_State *L);
>
> The fix is to use stronger typing like
>
> typedef int (*lua_CFunction) (lua_State *L);
>
> I just commited new changes to the trunk which fix this problem. Update to that version and tell me if you are having any more problems. Thanks.
>
> ~ Clay
>
> daerid wrote:
>> I'm trying to work with the lua D port at
>> http://svn.dsource.org/projects/bindings/trunk/lua/
>> And I ran into an interesting error:
>> "cannot implicitly convert expression (#luaopen_base) of type int(C *)(lua_State * L) to int(C *)(lua_State* L)"
>> When compiling this code:
>> -----------------------------------------------
>> import lua.lua;
>> import lua.lualib;
>> import lua.lauxlib;
>> int main(char[][] args)
>> {
>> lauL_reg lr;
>> lr.name = "base";
>> lr.func = &luaopen_base;
>> return 0;
>> }
>> -----------------------------------------------
>> Anybody have any idea what's going on here?
>> Bryan Ross
>> daerid@gmail.com
|
December 24, 2005 Re: Interesting error | ||||
---|---|---|---|---|
| ||||
Posted in reply to clayasaurus | I also got this fixed by a different route. All the functions in lua.d are declared like: extern int lua_gettop (lua_State *L); whereas luaopen_base is declared like so: /*LUA_API*/ int luaopen_base (lua_State * L); so I replaced all the /*LUA_API*/ entries with 'extern' and all was good in the world. In article <dof6qb$798$1@digitaldaemon.com>, clayasaurus says... > >The problem seemed to be that lua_CFunction was defined as > >alias int (*lua_CFunction) (lua_State *L); > >The fix is to use stronger typing like > >typedef int (*lua_CFunction) (lua_State *L); > >I just commited new changes to the trunk which fix this problem. Update to that version and tell me if you are having any more problems. Thanks. > >~ Clay > >daerid wrote: >> I'm trying to work with the lua D port at http://svn.dsource.org/projects/bindings/trunk/lua/ >> >> And I ran into an interesting error: >> >> "cannot implicitly convert expression (#luaopen_base) of type int(C *)(lua_State * L) to int(C *)(lua_State* L)" >> >> When compiling this code: >> >> ----------------------------------------------- >> import lua.lua; >> import lua.lualib; >> import lua.lauxlib; >> >> int main(char[][] args) >> { >> lauL_reg lr; >> lr.name = "base"; >> lr.func = &luaopen_base; >> return 0; >> } >> ----------------------------------------------- >> >> Anybody have any idea what's going on here? >> >> Bryan Ross >> daerid@gmail.com |
December 25, 2005 Re: Interesting error | ||||
---|---|---|---|---|
| ||||
Posted in reply to daerid | "daerid" <daerid@gmail.com> wrote ...
>I also got this fixed by a different route. All the functions in lua.d are
> declared like:
>
> extern int lua_gettop (lua_State *L);
>
> whereas luaopen_base is declared like so:
>
> /*LUA_API*/ int luaopen_base (lua_State * L);
>
> so I replaced all the /*LUA_API*/ entries with 'extern' and all was good
> in the
> world.
Sigh ... gotta' love that :-)
|
December 26, 2005 Re: Interesting error | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kris | I know. You'd think that the compiler would be smart enough to realize that a function declared (and not defined) inside an extern (C) block would be 'extern'. Also, IMO, extern is a storage-class identifier, isn't it? It shouldn't affect type resolution. Especially when it produces messages like: "Could not implicitly cast from type T to T" where both types are reportedly identical. Just a thought In article <dol316$25jd$1@digitaldaemon.com>, Kris says... > >"daerid" <daerid@gmail.com> wrote ... >>I also got this fixed by a different route. All the functions in lua.d are >> declared like: >> >> extern int lua_gettop (lua_State *L); >> >> whereas luaopen_base is declared like so: >> >> /*LUA_API*/ int luaopen_base (lua_State * L); >> >> so I replaced all the /*LUA_API*/ entries with 'extern' and all was good >> in the >> world. > > >Sigh ... gotta' love that :-) > > |
Copyright © 1999-2021 by the D Language Foundation