Skip to content

Compatible Layer Compiler Errors While Using MoonJIT #967

@atom0s

Description

@atom0s

Didn't want to make a pull request to fix this without first seeing if there is something I am missing config wise that would avoid this. I am new to sol3, and still getting used to how it is setup.

Environment setup:

The Lua 5.3 compat header has two errors in it while making use of MoonJIT which can be easily fixed. However, I am not sure if this is the appropriate fix for this, or if I am just overlooking a define.

The errors are:

compat-5.3.h(102,16): error C2371: 'lua_Unsigned': redefinition; different basic types

compat-5.3.h(157,1): warning C4005: 'lua_pushglobaltable': macro redefinition

Second is only a warning by default, but I generally compile with warnings as errors.

The first can be fixed by assuming LuaJIT is the only time this issue will be seen, as I did not have it while compiling with stock Lua. So I fixed that via:

#if !defined(LUAJIT_VERSION)
typedef size_t lua_Unsigned;
#endif

The second is fixed by just checking for existing definitions like the other functions near it:

#ifndef lua_pushglobaltable
#define lua_pushglobaltable(L) \
  lua_pushvalue((L), LUA_GLOBALSINDEX)
#endif

Edit; sorry forgot to include a small snippet:

// MoonJIT lib
#pragma comment(lib, "lua51.lib")

// General includes..
#include <sol/sol.hpp>
#include <Windows.h>
#include <string>
#include <vector>

int32_t __cdecl main(int32_t argc, char* argv[])
{
    sol::state lua;
    lua.open_libraries();
}

This is enough to produce these errors. Include paths point to sol and moonjit accordingly.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions