3 ms·
So, what's the point? Why not just use... v->data[i] = x; This is, drum roll... type checked by the compiler, unlike _V(). P.S. Stop casting the result
by klodolph 14y ago
So, what's the point? Why not just use...
v->data[i] = x;
This is, drum roll... type checked by the compiler, unlike _V().
P.S. Stop casting the result of malloc(), it makes you look like you're trying to write C++. There's no good reason for it in C, and there's a good reason not to do it (because it can mask an error if you forget to include <stdio.h>).
For this reason, and because it looks like you want generics, it sounds like you want to write C++. Why not write C++? Then you can just overload operator[] and go on your merry little way, without having to circumvent the type checker with macros.
- shadowmint 14y agoWho said anything about generics? You could just #define v(a) (a->data) and be done with it, it's true.