+ 4

Why is it so hard to write a generic list?

17th Feb 2018, 4:10 PM
Gleny Rebellow
Gleny Rebellow - avatar
4 Answers
+ 3
Are you talking about pure C language? It is possible to develop, but as you said it is difficult because C does not have template support. But you can use void types. you need to write a lot of boiler plate code.
17th Feb 2018, 4:56 PM
Ravi Chandra Enaganti
Ravi Chandra Enaganti - avatar
+ 2
C without the ++ doesn't support the features that make this job easier. You can't just grab objects by the parent class and without polymorphism you're left building all the support to do that yourself. Pointers help but they're a two edged sword as you still have to handle type detection yourself. It's a good academic exercise like programming logic using only nands but, if this is for a real world application, you should probably go for a language with at least objects support.
17th Feb 2018, 5:03 PM
John
John - avatar
0
Pointers are perfect for this in standard c. If you're having issues with it, it's likely because of the unusual operators and how they apply to their roles. Let us know if you are referring to a different C language.
6th Sep 2018, 4:36 AM
Joshua Kersey
Joshua Kersey - avatar