Hacker News new | ask | show | jobs
by xigoi 1161 days ago
Okay, so you write your own string library. Now you'd like to do the same thing for resizable arrays, so you write a resizable array li… oops, you can't, because C doesn't have parametric types.
2 comments

He didn't say "write your own library". He said "use" one (your own if you prefer). Or are you going to suggest there are no good string handling libraries for C?
It doesn't matter. My point is that it's not possible, not for you and not for anyone else, to implement a type-safe generic resizable array library in C.
Preprocessor macros are an entirely valid tool in the C language toolbox, even if demonized by C++ coders.
Even Macro Assemblers from the MS-DOS and Amiga days are better than C pre-processor macros.
it is black magic, absolutely respect C developers.
But the preprocessor is just simple text replacement, nothing magic about it.