├── LICENSE ├── README.md └── meme.jpeg /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021-2024 hirrolot 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # awesome-c-preprocessor 2 | 3 | > A list of awesome C preprocessor stuff 4 | 5 | 6 | 7 | See also: [_"The Preprocessor Iceberg Meme"_](https://jadlevesque.github.io/PPMP-Iceberg/). 8 | 9 | ## Metaprogramming frameworks 10 | 11 | - [`hirrolot/metalang99`](https://github.com/hirrolot/metalang99) -- Full-blown preprocessor metaprogramming. 12 | - [`boostorg/preprocessor`](https://github.com/boostorg/preprocessor) -- Boost.org preprocessor module. 13 | - [`boostorg/vmd`](https://github.com/boostorg/vmd) -- Boost.org VMD module. 14 | - [`rofl0r/order-pp`](https://github.com/rofl0r/order-pp) -- order-pp preprocessor library (standalone part of chaos-pp). 15 | - [`rofl0r/chaos-pp`](https://github.com/rofl0r/chaos-pp) -- chaos preprocessor library. this is what boost preprocessor derived from. 16 | - [`pfultz2/Cloak`](https://github.com/pfultz2/Cloak) -- A mini-preprocessor library to demonstrate the recursive capabilities of the preprocessor. 17 | - [`pfultz2/ZLang`](https://github.com/pfultz2/ZLang) -- A plugin framework for namespace macros in C/C++. 18 | - [`mcinglis/libpp`](https://github.com/mcinglis/libpp) -- Functional-programming macros for the C preprocessor. 19 | - [`mcinglis/macrofun`](https://github.com/mcinglis/macrofun) -- Standards-defying functional-programming macros for the C preprocessor. 20 | - [`gustedt/p99`](https://gitlab.inria.fr/gustedt/p99/) -- Macros and functions for C99. 21 | - [`davidgarland/ceano`](https://github.com/davidgarland/ceano) -- A collection of C preprocessor hackery. 22 | - [`twhitehead/c99-meta`](https://github.com/twhitehead/c99-meta) -- Abusing the C99 preprocessor for meta-programming. 23 | - [`metacall/core/source/preprocessor`](https://github.com/metacall/core/tree/develop/source/preprocessor) -- Preprocessor Library by Parra Studios. 24 | 25 | ## C language extensions 26 | 27 | - [`hirrolot/datatype99`](https://github.com/hirrolot/datatype99) -- Algebraic data types for C99. 28 | - [`hirrolot/interface99`](https://github.com/hirrolot/interface99) -- Zero-boilerplate interfaces for C99. 29 | - [`orangeduck/Cello`](https://github.com/orangeduck/Cello) -- Higher level programming in C. 30 | - [`CObjectSystem/COS`](https://github.com/CObjectSystem/COS) -- C Object System: a framework that brings C to the level of other high level programming languages and beyond. 31 | - [`small-c/obj.h`](https://github.com/small-c/obj.h) -- A single-header supports OOP in pure C. 32 | - [`shakna-israel/LetsDestroyC.md`](https://gist.github.com/shakna-israel/4fd31ee469274aa49f8f9793c3e71163#file-letsdestroyc-md) -- Let's Destroy C. 33 | - [`yulon/clofn`](https://github.com/yulon/clofn) -- A closure function implementation for C. 34 | - [`alexanderchuranov/Metaresc`](https://github.com/alexanderchuranov/Metaresc) -- META data and RESource library for C language. 35 | - [`Leushenko/C99-Lambda`](https://github.com/Leushenko/C99-Lambda) -- Purely evil preprocessor macros adding anonymous functions and closures to ISO C99. 36 | - [`Leushenko/Pyrite`](https://github.com/Leushenko/Pyrite) -- BASIC-style "compiler" as C syntax library. 37 | - [`emdash/goof`](https://github.com/emdash/goof) -- A toy functional language created through the abuse of C. 38 | - [`Qqwy/c_exceptional`](https://github.com/Qqwy/c_exceptional) -- A simple Exception-handling library for C99. 39 | 40 | ## Compilers/Interpreters 41 | 42 | - [`BlueFlo0d/CSP`](https://github.com/BlueFlo0d/CSP) -- Compile-time LISP interpreter on C macro preprocessor. 43 | - [`cospplredman/PPLISP`](https://github.com/cospplredman/PPLISP) -- A set of 45 macros that allow for lisp-like preprocessor meta programming. 44 | - [`Ferdi265/preprocessor_brainfuck`](https://github.com/Ferdi265/preprocessor_brainfuck) -- A brainfuck interpreter using only the C preprocessor. 45 | - [`orangeduck/CPP_COMPLETE`](https://github.com/orangeduck/CPP_COMPLETE) -- Brainfuck interpreter written in the C preprocessor. 46 | - [`mkotha/bfi`](https://github.com/mkotha/bfi) -- A brainfuck interpreter on the C preprocessor. 47 | - [`notfoundry/bf.h`](https://gist.github.com/notfoundry/fad611951bbcec68d72be4fa093537a8#file-bf-h) -- Brainfuck interpreter written in the C preprocessor. 48 | - [`notfoundry/ppasm`](https://github.com/notfoundry/ppasm) -- x86_64 macro assembler entirely in C preprocessor. 49 | 50 | ## Debuggers 51 | 52 | - [`ptaffet/preprocessor-debug`](https://github.com/ptaffet/preprocessor-debug) -- Observe how the C preprocessor expands your complicated macros. 53 | - [`notfoundry/ppstep`](https://github.com/notfoundry/ppstep) -- Interactive C/C++ preprocessor macro debugger. 54 | - [`messer-cpp/messer`](https://github.com/messer-cpp/messer) -- REPL for C preprocessor of C++17. 55 | 56 | ## Other projects 57 | 58 | - [`mcpp`](https://mcpp.sourceforge.net/) -- A portable C preprocessor. 59 | - [`swansontec/map-macro`](https://github.com/swansontec/map-macro) -- A recursive C preprocessor macro which performs an operation on each element of a list. 60 | - [`M4GNV5/CppFun`](https://github.com/M4GNV5/CppFun) -- Math in the C pre-processor by breaking up Numbers into arrays of 8 bits and implementing common operations on those arrays. 61 | - [`ramdeoshubham/macros`](https://github.com/ramdeoshubham/macros) -- A collection of commonly used C MACROS. 62 | - [`agrif/Makefile`](https://gist.github.com/agrif/6127126) -- A horrible, horrible, wonderful C Preprocessor hack library. 63 | - [`notfoundry/wtf.c`](https://gist.github.com/notfoundry/aa927a9ef07a3a5990b08c5e78b0b492) -- 4-bit ALU metaprogrammed in C11's \_Generic. 64 | - [`kcning/binom`](https://github.com/kcning/binom) -- C macro that computes binominal coefficient at compile time. 65 | - [`ldionne/cisp`](https://github.com/ldionne/cisp) -- A C preprocessor library implementing object semantics. 66 | - [`rofl0r/thread_wrapper`](https://github.com/rofl0r/thread_wrapper) -- A thread launcher wrapper macro which removes the boilerplate and allows to call any non-void function as a separate thread (needs BOOST preprocessor lib, which is C compatible). 67 | - [`18sg/uSHET`](https://github.com/18sg/uSHET/blob/c09e0acafd86720efe42dc15c63e0cc228244c32/lib/cpp_magic.h) -- A Malloc-Free SHET Client Library for Microcontrollers (`lib/cpp_magic.h`). 68 | - [`ScrimpyCat/CommonC`](https://github.com/ScrimpyCat/CommonC/blob/30983aa36b2e4e17ade1d0ad60ba7b27ccf16bad/CommonC/Template.h) -- Common utilities for C (`CommonC/Template.h`). 69 | - [`cher-nov/Gena`](https://github.com/cher-nov/Gena) -- Generic pseudo-templated containers for C. Written entirely in C89 with design inspired by the C++ STL. 70 | - [`DiscordPP/discordpp`](https://github.com/DiscordPP/discordpp) and [`DiscordPP/plugin-native`](https://github.com/DiscordPP/plugin-native) -- A modular Discord library and a module for it that use macros to define Discord API endpoints and objects. 71 | 72 | ## Articles 73 | 74 | - [_7 Scandalous Weird Old Things About The C Preprocessor_](https://blog.robertelder.org/7-weird-old-things-about-the-c-preprocessor/) by Robert Elder. 75 | - [_Coroutines in C_](https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html) by Simon Tatham. 76 | - [_IOCC "Best abuse of the C preprocessor"_](http://www.ioccc.org/2001/herrmann1.hint) by Immanuel Herrmann. 77 | - [_Metaprogramming custom control structures in C_](https://www.chiark.greenend.org.uk/~sgtatham/mp/) by Simon Tatham. 78 | - [_Advanced metaprogramming in C_](https://250bpm.com/blog:56/) by Martin Sústrik. 79 | - [_C/C++ Preprocessor Metaprogramming_](http://saadahmad.ca/cc-preprocessor-metaprogramming-2/) by Saad Ahmad. 80 | - [_The Love/Hate Relationship with the C Preprocessor: An Interview Study_](https://www.cs.cmu.edu/~ckaestne/pdf/ecoop15.pdf) by Flávio Medeiros, Christian Kästner, Márcio Ribeiro, Sarah Nadi, Rohit Gheyi. 81 | - [_Outperforming LAPACK with C metaprogramming_](https://wordsandbuttons.online/outperforming_lapack_with_c_metaprogramming.html) by Oleksandr Kaleniuk. 82 | - [_C Pre-Processor Magic_](http://jhnet.co.uk/articles/cpp_magic) by Jonathan Heathcote. 83 | 84 | ### [Jens Gustedt's Blog](https://gustedt.wordpress.com/category/c99/preprocessor/) 85 | 86 | Some worth-noting articles: 87 | 88 | - [_Handling control flow inside macros_](https://gustedt.wordpress.com/2011/02/02/handling-control-flow-inside-macros/) 89 | - [_Scope Bound Resource Management with `for` Scopes_](https://gustedt.wordpress.com/2010/08/14/scope-bound-resource-management-with-for-scopes/) 90 | - [_Detect empty macro arguments_](https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/) 91 | - [_Default arguments for C99_](https://gustedt.wordpress.com/2010/06/03/default-arguments-for-c99/) 92 | 93 | ## SO questions 94 | 95 | - [_Is the C99 preprocessor Turing complete?_](https://stackoverflow.com/questions/3136686/is-the-c99-preprocessor-turing-complete) 96 | - [_Can we have recursive macros?_](https://stackoverflow.com/questions/12447557/can-we-have-recursive-macros) 97 | - [_Overloading Macro on Number of Arguments_](https://stackoverflow.com/questions/11761703/overloading-macro-on-number-of-arguments) 98 | - [_The most useful user-made C-macros (in GCC, also C99)?_](https://stackoverflow.com/questions/1772119/the-most-useful-user-made-c-macros-in-gcc-also-c99) 99 | - [_Understanding DEFER and OBSTRUCT macros_](https://stackoverflow.com/questions/29962560/understanding-defer-and-obstruct-macros) 100 | -------------------------------------------------------------------------------- /meme.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hirrolot/awesome-c-preprocessor/a443ea62ad1c786c7fbeaa0f3526cf9b6636ae50/meme.jpeg --------------------------------------------------------------------------------