Thread overview | |||||
---|---|---|---|---|---|
|
August 02, 2016 [Derelict-Lua] compiler error when lua_register is called | ||||
---|---|---|---|---|
| ||||
So basically I get the error "function button(lua_State* L) is not callable using argument types ()" whenever I try to lua_register a function. ``` lua_register(L,"button",button); ``` but whenever I use the function pointer I get the error "lua_register is not callable using argument types (lua_State*, char*,extern (C) int function(lua_State* L)" ``` lua_register(L,"button",&button); ``` Is this a bug, or am I doing something wrong here? |
August 02, 2016 Re: [Derelict-Lua] compiler error when lua_register is called | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jack | On Tuesday, 2 August 2016 at 14:23:55 UTC, Jack wrote: > So basically I get the error "function button(lua_State* L) is not callable using argument types ()" whenever I try to lua_register a function. > ``` > lua_register(L,"button",button); > ``` > but whenever I use the function pointer I get the error "lua_register is not callable using argument types (lua_State*, char*,extern (C) int function(lua_State* L)" > ``` > lua_register(L,"button",&button); > ``` > > Is this a bug, or am I doing something wrong here? lua_register takes function pointers that in the form of lua_CFunction, an alias you can find declared in derelict.lua.types [1]. As you'll see there, it is declared to be both extern(C) and nothrow. Make your button function nothrow an you should be good to go. [1] https://github.com/DerelictOrg/DerelictLua/blob/master/source/derelict/lua/types.d#L103 |
August 03, 2016 Re: [Derelict-Lua] compiler error when lua_register is called | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Tuesday, 2 August 2016 at 16:44:39 UTC, Mike Parker wrote:
> On Tuesday, 2 August 2016 at 14:23:55 UTC, Jack wrote:
>> [...]
>
> lua_register takes function pointers that in the form of lua_CFunction, an alias you can find declared in derelict.lua.types [1]. As you'll see there, it is declared to be both extern(C) and nothrow. Make your button function nothrow an you should be good to go.
>
> [1] https://github.com/DerelictOrg/DerelictLua/blob/master/source/derelict/lua/types.d#L103
Thank you!
|
Copyright © 1999-2021 by the D Language Foundation