Add generic containers and foreach loops to an existing C project without rewriting it in C++.
Experiment with automatic memory management in C by letting Cello clean up allocated objects instead of tracking every free() call.
Use Cello as a teaching tool to understand how runtime type information and method dispatch work at the C level.
Requires a C compiler and make, the author recommends testing on personal projects only due to known quirks.
Cello is a library for the C programming language that adds features normally found in higher-level languages. C is fast and widely used, but it lacks built-in support for things like generic containers that hold any type of data, automatic memory cleanup, error handling via exceptions, and object-like behavior where the same function name works differently depending on the type it receives. Cello adds all of these on top of standard C. With Cello you can create arrays and tables that hold typed values, loop over collections with a foreach keyword, and define custom types that can be compared, printed, and hashed without writing that logic from scratch each time. Optional garbage collection means you can allocate objects and let Cello clean them up automatically when they go out of scope, rather than tracking every free() call manually. The library works by attaching type information to pointers at runtime, a technique the author describes as a fat pointer approach. This lets functions inspect what type of object they received and dispatch behavior accordingly, similar to how object-oriented languages handle method calls. Existing C structs can be registered with Cello to gain these abilities without rewriting them. The author is clear that Cello started as an experiment to see how far C could be pushed, and recommends trying it on a personal project before anything production-facing. The README notes that the library has quirks and that teams working under deadlines would find better tooling and community support in C++ instead. The source code and documentation are available, and contributions are welcome. The author also links to a book they wrote on building a Lisp interpreter in C.
← orangeduck on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.