We have a structure defined something like (it does a lot more than this, but this is all that's necessary for my problem):
Now I populate an array of these structures as follows: first choose data from source and if for some reason it isn't valid, we default val to default. Now the problem I have is that sometimes val isn't an int - sometimes it's a float. I have been solving this by putting in the IEEE floating point representation of the floating point default (ie, 0x428C0000 for 70.0) but we know it's wrong to using the underlying floating point representation this way. We would like to do something and be able to type in 70.0 and let the compiler figure it out.Code:typdef struct { some_data_type source; void* val; int default }blah_st;
Now we have a solution for this that involves fairly significant rework. Can you see any way to do this without using things like void* to default, etc that would cause me to have to rework this data structure?