I'm experimenting with generic-like code and I have a function like this (a lot of not relevant code removed):
typedef uint8_t (*struct_converter_t)(void *, char *);
void convert_struct(
struct_converter_t converter, // this is a function
const char * file_name
){
some_struct_t * some_struct;
converter(some_struct, some_string_buffer);
}
And when I try to assign a function that takes some_struct_t
(not void *
):
static uint8_t some_converter(some_struct_t * vd, char * s);
to my struct_converter_t
like this:
struct_converter_t converter = some_converter; // WARNING HERE
I'm getting this:
initialization of 'struct_converter_t' {aka 'unsigned char (*)(void *, char *)'} from incompatible pointer type 'uint8_t (*)(some_struct_t *, char *)' {aka 'unsigned char (*)(struct <anonymous> *, char *)'} [-Wincompatible-pointer-types]
I'm not experienced in C and I would like to know if there is a way to get rid of this warning elegantly.