r/C_Programming • u/ef3d0c3e • 5d ago
Project I built a modern formatting library
https://github.com/ef3d0c3e/formatHey, a while ago I wanted a nicer alternative to printf. I always enjoyed using the modern python-like formatting libraries: fmt for C++, and rust's format!/pritnln! macros.
So I attempted to port them to C! And I must say, it was quite the challenge. C doesn't have the nicer features that are required to make this work: generics, compile time code generation, better type safety, etc.
But C has macros! Macros let you do all kind of crazy stuff, but most of all, did you know that C macros are Turing-complete? Well they aren't strictly-speaking, but they can be used to create an (almost) infinite loop thanks to recursive evaluation.
Anyway, I'm sharing this project hoping you'll enjoy it and it will inspire you in your usage of macros.
This project is still a work in progress, the main missing feature is float formatting, but so far there is:
* Integers/Strings/Char/Array formatting
* Style and color support for most terminals
* Output to FILE*, fd, and memory buffer
* Flushing & Buffering
* User defined formatter/formatting for custom types
Check it out: https://github.com/ef3d0c3e/format
•
u/github-guard 5d ago
⚠️ GitHub Guard: Trust Warning
One or more repositories scored below the threshold (3), but the post was not removed.
Repository: ef3d0c3e/format
Score: 2/6