For current SDCC, this code:
static int cmp_eq (long arg1, long arg2)
{
return arg1 != arg2;
}
struct op {
const char *op_name;
void (*op_func)(void);
};
const struct op string_binop1[] = {
{"=", cmp_eq},
};
const struct op string_binop2[] = {
{"=", &cmp_eq},
};
const struct op string_binop3[] = {
{"=", (void (*)(void*))cmp_eq},
};
const struct op string_binop4[] = {
{"=", (void (*)(void*))&cmp_eq},
};
Results in errors (at least for mcs51, stm8, z80, but probably all backends):
test.c:12: error 78: incompatible types
from type 'int function ( long-int auto, long-int auto) fixed'
to type 'void function ( ) fixed'
test.c:16: error 78: incompatible types
from type 'int function ( long-int auto, long-int auto) fixed'
to type 'void function ( ) fixed'
test.c:20: error 78: incompatible types
from type 'void function ( void generic* fixed) code* fixed'
to type 'void function ( ) fixed'
test.c:24: error 78: incompatible types
from type 'void function ( void generic* fixed) code* fixed'
to type 'void function ( ) fixed'
By section 6.6 of the ISO C11 standard (and probably all other C standards as well) all these should work.
Philipp
In revision [r10034], I fixed the two cases with an explicit cast, the other two are still open.
Philipp