4 ms·
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
by iafisher 5y ago
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".
- deleted 5y ago[deleted]
- bitwize 5y agoMacros 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.
- anaerobicover 5y agoAlso OpenSSL
- jcelerier 5y ago> 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!"
- ganafagol 5y agoBy the way, the "safe" alternative in your post roughly describes how C++ started its life.
- efficax 5y agoThis 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 https://github.com/attractivechaos/klib