Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Author here. I wish I had made it clearer that the intent of the post was "this is an interesting and surprising thing you can achieve in C" and not "this is a good idea for a real software project" or "this is a reason to use C instead of C++/Rust/Go".


Macros of this sort are indeed used to define stacks, queues, deques, and other generic data structures in the NetBSD (and presumably other BSDs) source code. So the pattern is used in real software projects.


Also OpenSSL


> Author here. I wish I had made it clearer that the intent of the post was "this is an interesting and surprising thing you can achieve in C" and not "this is a good idea for a real software project" or "this is a reason to use C instead of C++/Rust/Go".

thanks, because from my experience edgy first year comp.sci. students will see that article and be like "see ! we don't need anything more than C!"


By the way, the "safe" alternative in your post roughly describes how C++ started its life.


This is in fact a pretty common pattern in production code.

Here's an entire suite of type safe generic data structures in C: https://github.com/attractivechaos/klib




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: