In C++ you can have both generic and type safe containers by using templates. However in C, if you want generic containers, you have to (afaik) use void*
, which means you lose type safety. To have type safe containers, you would have to reimplement them for every type of data you want to hold.
Given that C follows a more the-programmer-knows-what-he's-doing philosophy than C++, what would be the more idiomatic thing to do in C: use generic containers with void*
, or make custom containers for every type of data?