Skip to content

m-schmoock/lcpp

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

===

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 michael@schmoock.net

About

A Lua C PreProcessor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published