No problem. I'm using this feature in my RTOS project. SDCC was one of the supported compilers.
In example below: typedef void func(); void f(int i) { (void) i; } func *g = f; compiler reports error 78: incompatible types.
Below an example of a code that should compile without errors. typedef void func(); void f(int i) { (void) i; } void main() { func *g = (func *)f; g(0); }
Below an example of a code that should compile without errors. typedef void (*func)(); void f(int i) { (void) i; } void main() { func g = f; g(0); }
Below an example of a code that should compile without errors. typedef void (*func)(); void f(int i) { (void) i; } int main() { func g = f; g(0); }
too many parameters error
Interesting example: struct _s { char t[10]; }; struct _s s1; void *v1 = &s1 + 1; // ERROR void *v2 = (struct _s *)&s1 + 1; // OK void main() { struct _s s2; void *v3 = &s2 + 1; // OK void *v4 = (struct _s *)&s2 + 1; // OK void *v5 = &s1 + 1; // OK! void *v6 = (struct _s *)&s1 + 1; // OK! }
Interesting example: struct _s { char t[10]; }; struct _s s1; void *v1 = &s1 + 1; // ERROR void *v2 = (struct _s *)&s1 + 1; // OK void main() { struct _s s2; void *v3 = &s2 + 1; // OK void *v4 = (struct _s *)&s2 + 1; // OK }