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

i386 __attribute__((fastcall)) #302

Open
namtsui opened this issue Nov 9, 2022 · 1 comment
Open

i386 __attribute__((fastcall)) #302

namtsui opened this issue Nov 9, 2022 · 1 comment
Labels
wait-for-response Waiting for response from the issue author

Comments

@namtsui
Copy link

namtsui commented Nov 9, 2022

on i386 32-bit openbsd with luabridge 9092ace I get a compilation error when trying to addFunction with a function that uses attribute fastcall. Removing fastcall allows the program to compile.

relevant section of Namespace.h:

   1280     //----------------------------------------------------------------------------
   1281     /**
   1282         Add or replace a free function.
   1283     */
   1284     template<class ReturnType, class... Params>
   1285     Namespace& addFunction(char const* name, ReturnType (*fp)(Params...))
   1286     {

reproducible example:

// c++ -I/usr/local/include -I/usr/local/include/lua-5.3 /usr/local/lib/liblua5.3.so.5.3 luabridge.cpp

#include <vector>
#include <cmath>
#include <iostream>
#include <lua.hpp>
#include <LuaBridge/LuaBridge.h>

using std::vector;
using std::cout;
using std::endl;

//basic types
typedef int8_t  s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

typedef uint8_t  u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;

typedef float f32;
typedef double f64;

#define DYNACALL __attribute__((fastcall))

u8 DYNACALL _vmem_readt_8(u32 addr)
{
        return 23;
}

using namespace luabridge;

int main()
{
        static lua_State *L;

        getGlobalNamespace(L)
                .beginNamespace("memory")
                        .addFunction("read8", _vmem_readt_8)
                .endNamespace();
        return 0;
}
$ c++ -I/usr/local/include -I/usr/local/include/lua-5.3 /usr/local/lib/liblua5.3.so.5.3 luabridge.cpp         
luabridge.cpp:42:5: error: no matching member function for call to 'addFunction'
                        .addFunction("read8", _vmem_readt_8)
                        ~^~~~~~~~~~~
/usr/local/include/LuaBridge/detail/Namespace.h:1326:16: note: candidate function not viable: no known conversion from 'DYNACALL u8 (u32) __attribute__((fastcall))' (aka 'unsigned char (unsigned int) __attribute__((fastcall))') to 'int (*const)(lua_State *)' for 2nd argument
    Namespace& addFunction(char const* name, int (*const fp)(lua_State*))
               ^
/usr/local/include/LuaBridge/detail/Namespace.h:1263:16: note: candidate template ignored: could not match 'function<type-parameter-0-0 (type-parameter-0-1...)>' against 'unsigned char (*)(unsigned int) __attribute__((fastcall))'
    Namespace& addFunction(char const* name, std::function<ReturnType(Params...)> function)
               ^
/usr/local/include/LuaBridge/detail/Namespace.h:1285:16: note: candidate template ignored: deduced type 'unsigned char (*)(unsigned int)' of 2nd parameter does not match adjusted type 'DYNACALL u8 (*)(u32) __attribute__((fastcall))' (aka 'unsigned char (*)(unsigned int) __attribute__((fastcall))') of argument [with ReturnType = unsigned char, Params = <unsigned int>]
    Namespace& addFunction(char const* name, ReturnType (*fp)(Params...))
               ^
1 error generated.
@dmitry-t
Copy link
Collaborator

dmitry-t commented Mar 4, 2023

Sorry for a late response, do you have a solution now?

@dmitry-t dmitry-t added the wait-for-response Waiting for response from the issue author label Mar 4, 2023
bsdcode added a commit to bsdcode/freebsd-ports that referenced this issue Nov 17, 2024
Building with lua support fails on i386, see also [1]. Make lua support
configurable with port option LUA and exclude this option on i386.

[1] vinniefalco/LuaBridge#302
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wait-for-response Waiting for response from the issue author
Projects
None yet
Development

No branches or pull requests

2 participants