What do I know is that C has _Generic macros. One can even implement some limited typename()
for ANSI C (just like it is mentioned here).
But can I implement something like std::is_pointer in C? For example:
#define IS_POINTER_TYPE(x) // ?
struct Vec2 {
float x;
float y;
};
int main(int argc, char* argv[], char* env[])
{
IS_POINTER_TYPE(Vec2*); // true
IS_POINTER_TYPE(int*) // true
IS_POINTER_TYPE(char) // false
IS_POINTER_TYPE(const int) // false
}
Can I do this for variables, not types? Thank you.
UPD: This solution is not portable and not generic unfortunately. One require monkey-job copy-pasting or code generation to make all your structures conform to this notation. You guys guided me to a decision if you don't require 100% accuracy and can tolerate some false-positives.