I have code in C having switch case statement as below.
float value_calc ( Type_t type, void *in_data)
{
switch ( type)
{
case 0:
{
int * data = (int*)in_data;
}
break;
case 1:
{
float * data = (float*)in_data;
}
break; <-- error :- data: redefinition; different basic types.
case 3:
{
double * data = (double*)in_data;
}
break;
default:
return 0;
}
for (int i =0; i< 1024; i++)
{
float capture = * (data + i) + diff; <-- error identifier data is undefined
}
here, Type_t
is enum having data type int =0
as first member and other member in sequence are float
and double
.
I have tried without curly braces and also by putting semi-colon as per mentioned here in some answers. But it is not getting compiled.
How do I correctly mention as the variable will different data type as per case.