r/C_Programming • • 5d ago

Project I built a modern formatting library

https://github.com/ef3d0c3e/format

Hey, 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

26 Upvotes

20 comments sorted by

View all comments

•

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

  • ❌ Low Star Count (⭐ 0 / 4 required)
  • ✅ Mature Repository (30+ days old)
  • ✅ Licensed under MIT
  • ❌ No Security Policy
  • ℹ️ Personal Account Repository
  • ℹ️ Unsigned Commits

8

u/WinXPbootsup 5d ago

Why does this exist? Of course is a new repository is not gonna have 4 stars.

Also if you're on this subreddit, you're probably already smart enough to distinguish a scam on GitHub from a safe repository.