I am in a situation where my code receives data from somewhere outside my control in the form of a long list floats.
These numbers are distributed among various functions.
void myfunc(struct floatstruct* fs);
which take structures of the following form:
struct floatstruct
{
float a;
float b;
float c;
};
You get the idea.
I was wondering if there is a way to safely pass a float array in floatstructto transfer data directly to myfunc. I can add alignment attributes to floatstructif necessary.
An example of the desired behavior:
struct mystruct1
{
float a;
float b;
float c;
};
struct mystruct2
{
float x;
float y;
};
extern void myfunc1(mystruct1*);
extern void myfunc2(mystruct2*);
void process_data(float* numbers)
{
myfunc1((struct mystruct1*)numbers);
myfunc2((struct mystruct2*)(numbers + 3));
}
The ideal solution, of course, should change the system. But I am looking for solutions according to the given parameters.
source
share