Is there a way to print out the type of a variable/pointer in C?
c, types
Solution
try debugging using GDB, it will print all properties associated with the variable including it's type. But, your program should compile before using GDB.
Problem
I want to print out (or otherwise ascertain) the type of some variable in my program. Is there a good way to do it? By good, I mean a way that works, even if it means intentionally throwing compiler errors. For example: ``` client.c:55: error: incompatible types in assignment ``` is the error I'm getting right now. What I WANT is it to tell me something like: ``` client.c:55: error: attempting to assign type struct a to type struct b ``` or a function that I can use like so: ``` printf(gettype(x)); ``` which would output: ``` struct b ```