• Stars
    star
    130
  • Rank 276,745 (Top 6 %)
  • Language
    C
  • Created over 11 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Lua C PreProcessor

===

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

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 [email protected]