Is it possible to have a function or macro to return variable type? I need to implement something like a conditional typedef. Example:
(var_type) foo (char a)
{
if (a == 1)
return char;
else
return int;
}
Such that I could :
foo(1) variable;
Note: The above is just a pseudo-code.
You can’t do that. You could allocate your object on the heap and return a
void *to it. Or perhaps you could use a union.