I want to call a function of type
foo(void * data) having as input parameter a struct variable.
I have heard that when the input format is of type void, it accepts every type of input variable type. Nevertheless, I get an error message.
struct info inserter_info;
inserter_info.element = 0;
inserter() is prototyped as
void * inserter(void * data).
I tried casting but then also I got error messages.
Best How To :
I have heard that when the input format is of type void, it accepts every type of input variable type
Absolutely wrong !!!
void means nothing. It accepts nothing.
void * is considered a generic pointer. To quote the
C11 standard document, chapter 126.96.36.199, pointers, paragaraph 1,
A pointer to void may be converted to or from a pointer to any object type. A pointer to any object type may be converted to a pointer to void and back again; the result shall compare equal to the original pointer.
using this attribute, many a times, the function parameter is written as
void * so that, the function can accept different types of pointer and then, inside function body, based on some other paramater, that received pointer is converted (casted) back to the actual pointer type before using it.
If you check properly, the parameter to the function is not
You need to call your function like
P.S - Your compiler should have warned you regarding the mismatch.