Skip to content

How do I call lua_pushcfunction ? #17

@markusbkk

Description

@markusbkk

I'm rather new to D so maybe I'm simply missing some fundamentals, but how do I add a C function to the stack?

My code:

import raylib;
import bindbc.lua;

extern(C) static int hello(lua_State *L) {
    DrawText("Hello, LUA!", 960, 300, 28, Colors.BLACK);
    return 1;
}

extern(C) void main()
{
    LuaSupport ret = loadLua();
    lua_State* mystate = luaL_newstate();
    luaL_openlibs(mystate);
    lua_pushcfunction(mystate, &hello);
}

This fails with cannot pass argument `& hello` of type `extern (C) int function(lua_State* L)` to parameter `extern (C) int function(lua_State*) nothrow f`

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions