I cannot understand why different code works as it will be identical.
#include <stdio.h>
void foo() {
printf("Hello\n");
}
void foo1(void fn()) {
(*fn)();
fn();
}
void foo2(void (*fn)()) {
(*fn)();
fn();
}
int main(void) {
foo1(foo);
foo2(foo);
return 0;
}
If they identical then why this does not work?
typedef void F1(), (*F2)();
int main(void) {
F1 f1;
F2 f2;
// error: lvalue required as left operand of assignment
f1 = foo1;
f2 = foo2;
return 0;
}
P.S.
My interest are not in the typedef
(second example).
I have questions only about the first example.
That is:
- Function declartions
- Function invocations