Lcpp
A Lua C PreProcessor
Install / Use
/learn @m-schmoock/LcppREADME
lcpp - a C-PreProcessor for Lua 5.1 and LuaJIT ffi integration
This module offers a standard preprocessor for C code in pure Lua. The primary usecase is to enable LuaJIT ffi preprocessing. But you can also preprocess any other stuff (even Lua code itself)
Links
- Project page http://lcpp.schmoock.net
- GitHub Page https://github.com/m-schmoock/lcpp
- Lua http://www.lua.org/
- LuaJIT http://luajit.org
Usage
-- load lcpp (ffi.cdef wrapper turned on per default)
local lcpp = require("lcpp")
-- just use LuaJIT ffi and lcpp together
ffi.cdef("#include <your_header.h>")
-- or compile some code by hand
local result = lcpp.compile("...")
local out = lcpp.compile([[
#define MAXPATH 260
typedef struct somestruct_t {
void* base;
size_t size;
wchar_t path[MAXPATH];
} t_exe;
]])
Supports
features:
transparent LuaJIT ffi extension
replacement macros
macro chaining
functional macros
multiline macros
expressions (defined(xyz) && ...)
concat operator ("##")
screen C single- and multiline comments
directives:
#include
#define
#undef
#pragma
#error
#if
#ifdef
#ifndef
#else
#else if
#elif
#endif
macros:
__LINE__
__FILE__
__DATE__
__TIME__
__LCPP_INDENT__
Make targets
make test # run the included test cases
make doc # ldoc must be installed
License
MIT licencse included in lua modue.
2012-2014 Michael Schmoock michael@schmoock.net
Related Skills
node-connect
343.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
92.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
