pkulchenko / wxlua

wxlua: Lua bindings for wxWidgets cross-platform GUI toolkit; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and wxWidgets 3.x
307 stars 59 forks source link

Win10+VC15 fails compilation against Lua 5.4.2 and wxWidgets 3.0.1.4 #79

Closed decuant closed 3 years ago

decuant commented 3 years ago

Hi Paul,

I was compiling all the whole lot to get Lua 5.4.2 and latest wxWidgets 3.0.1.4 against your wxLua 3.1.0.0, but it fails.

The correction has to be made in file wxlstate.cpp

----> moved lua_CPCall from outside to inside define check 502 <---------

#if LUA_VERSION_NUM < 502

int wxLuaState::lua_CPCall(lua_CFunction func, void *ud)
{
    wxCHECK_MSG(Ok(), 0, wxT("Invalid wxLuaState"));
    return lua_cpcall(M_WXLSTATEDATA->m_lua_State, func, ud);
}

...

Can you please have a look and possibly fix for everybody?

I have built wx.dll for 64bit correctly with this fix.

Ciao

Antonio

pkulchenko commented 3 years ago

@decuant, what's the error you are getting?

The fix you are proposing is insufficient, as there has to be the else part to that if check, but I'm not yet sure what it should be.

pkulchenko commented 3 years ago

@decuant, lua_cpcall is deprecated in lua 5.2+, but there is a define in wxldefs.h that is supposed to compensate for that. It doesn't seem to be used in your case, that's why I'm curious what error you are getting.

decuant commented 3 years ago

C:\wxlua-master\wxLua\modules\wxlua\wxlstate.cpp(1871): error C3861: 'lua_cpcall': identifier not found

I have reverted code back to get the error. Is at line 1871 of wxlstate.cpp.

With find in files this call is defined in wxldefs.h (it is the file I used as hint for solving the problem, since it mentions Lua 5.2).

Your point is correct (about versioning).

pkulchenko commented 3 years ago

@decuant, can you try the following patch:

diff --git a/wxLua/modules/wxlua/wxldefs.h b/wxLua/modules/wxlua/wxldefs.h
index a9c5161..572a045 100644
--- a/wxLua/modules/wxlua/wxldefs.h
+++ b/wxLua/modules/wxlua/wxldefs.h
@@ -40,12 +40,14 @@ extern "C"
         #endif

         // These are #defined with LUA_COMPAT_ALL (but we don't require that)
-        #ifndef lua_strlen 
+        #ifndef lua_strlen
             #define lua_strlen(L,i)             lua_rawlen(L, (i))
             #define lua_objlen(L,i)             lua_rawlen(L, (i))
             #define lua_equal(L,idx1,idx2)      lua_compare(L,(idx1),(idx2),LUA_OPEQ)
             #define lua_lessthan(L,idx1,idx2)   lua_compare(L,(idx1),(idx2),LUA_OPLT)
+        #endif

+        #ifndef lua_cpcall
             #define lua_cpcall(L,f,u)           (lua_pushcfunction(L, (f)), \
                                                 lua_pushlightuserdata(L,(u)), \
                                                 lua_pcall(L,1,0,0))
decuant commented 3 years ago

Hi Paul,

you fixed this error, very good. I tested the new wx.dll just to make sure.... and you can close the ticket.

Just before leaving, I wanted to say that I feel lost without ZeroBrane, I don't know how to insert a menu entry to switch interpreter to be 5.4.2. Please consider adding support for it.

Thank you again

pkulchenko commented 3 years ago

Pushed the changes. Lua 5.4 support is coming; you can track it in https://github.com/pkulchenko/ZeroBraneStudio/issues/1075.