C++23 module binding for Lua C API: import mcpplibs.capi.lua;. Uses xmake as primary build system, GCC 15.1 for C++23 module support.
- xlings provides both xmake and GCC 15.1; install via
curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/refs/heads/main/tools/other/quick_install.sh | XLINGS_NON_INTERACTIVE=1 bash - After installing xlings, run
xlings install gcc@15.1 -yto get GCC 15.1 - PATH must include
$HOME/.xlings/binand$HOME/.xlings/subos/current/bin
Standard commands documented in README.md:
xmake f -m release -yto configurexmake -y -j$(nproc)to buildxmake run capi_lua_testto run tests (97 tests)xmake run basic|table|function|evalto run examples
- GCC C++ modules + C headers: Lua headers must be wrapped with explicit
extern "C"viasrc/capi/lua_headers.hin the global module fragment. Without this, GCC applies C++ name mangling to the C functions and linking fails. This is a GCC 15.1 behavior with C++ modules. - Interface + implementation split: The module uses
.cppmfor declarations and.cppfor definitions. Functions cannot beinlinein the.cppmbecause GCC would inline them at the import site where the Lua C declarations are not available, causing link errors. - Lua dependency: xmake auto-downloads Lua via
add_requires("lua"). Bothtests/xmake.luaandexamples/xmake.luamust include their ownadd_requires("lua")andadd_packages("lua"). - Test target: The test target is named
capi_lua_test(nottemplates_testfrom the original template). - mcpp style: Follow mcpp-style-ref. See
.agents/skills/mcpp-style-ref/SKILL.mdfor details.