Hey everyone, I have a problem. This is what I'm trying to do (but a lot simplified):
that's the basic idea of what I want to do, but this won't work since typedef can't be used inside a function's definition. Is there any alternative way to achieve the same purpose? (function2 is always called after myFunction) :confused:Code:int a;
//stuff
void myFunction()
{
if(a == 1)
typedef char data_type;
else if(a == 2)
typedef short data_type;
else
typedef long data_type;
}
void function2()
{
data_type* x = (data_type*)myData; //myData is a void*
//do stuff with x
}