News for hackers. Stuff that matters.
Re:The Unreasonable Effectiveness of C by stinos on Thursday January 10, 2013 @12:11PM (#5038156)
well the thing is, it also works for std::vector<string>, or std::vector<int>, or anything you want. Last time I checked in C you'd have to either duplicate all your array code for each type or resort to something like void*. Only for that I'd use C++ (yes, you can use it without classes if you want).
Re:The Unreasonable Effectiveness of C by digeridoo on Thursday January 10, 2013 @12:51PM (#5038476)
Last time I checked in C, all pointer types where the same storage size. There's no need to define the same data structure multiple times by using templates. You just use casts.
Re:The Unreasonable Effectiveness of C by sbmassey on Thursday January 10, 2013 @02:20PM (#5039093)
... which is fine for creating data structures containing pointers to things created elsewhere, but it doesn't work if you want your data structures to contain more complex data types, without the overhead of another layer of pointer redirections.
Re:The Unreasonable Effectiveness of C by spc476 on Thursday January 10, 2013 @02:30PM (#5039175)
Nope. There is no need in C for all pointers to be the same size. An implementation is free (and there indeed, exist some) where a char* is a different size from an int. You can* safely cast any data pointer to void, and a void back to any data pointer. POSIX requires that function pointers can do this; the C standard doesn't require it.

Now, that said, it is possible to write generic link list routines (I've done it) but the devil is in the details.