by akp__ · 10y ago · 0 comments
The main alternative, other than hardcoding an element type, is to use macros and pass the element type in the definition.
Sometimes you just don't have the option of a C++ compiler. Also, and this was a situation I was in recently, I needed a collection in a small area of my C code so it really didn't warrant a toolset change.
typedef struct Strref_t {
char* str;
size_t ref;
} Strref;
There, just pass a pointer of that type around.