Open namtsui opened 1 year ago
on i386 32-bit openbsd with luabridge https://github.com/vinniefalco/LuaBridge/commit/9092ace9615d14e3f5926f2e8a3b612ddc6c8efa 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.
Sorry for a late response, do you have a solution now?
on i386 32-bit openbsd with luabridge https://github.com/vinniefalco/LuaBridge/commit/9092ace9615d14e3f5926f2e8a3b612ddc6c8efa 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:
reproducible example: