I have a structure like this:
typedef struct {
float batch;
float length;
uint32_t test;
char val[0];
}
PARAM;
And am calling a function with this format:
void fillValues(float val, float len, uint32_t tmp, const void* prw);
I declare the structure and allocate some memory:
PARAM *first = calloc(10, sizeof(PARAM));
The problem I am having is if I print the values of first->data
before calling the function, it contains as expected but if I call the function:
fillValues (test, first->batch, first->length,
first->test, &first->val);
and try and print prw inside, it contains nothing.
I think I am passing the value incorrectly because it is declared as a char array but the function parameter is a const void *. P.S. I don't want to change the fucntion param type.
The only part where prw is used in fillValues is converting to a double:
double *value
value = (double*)first->data;
*value = *(const double*)pwr;