function pointer compare
[tinycc.git] / tests / tests2 / 42_function_pointer.c
blob6b9db61a44a9c85f464d67f06d711de7a9e75ec4
1 #include <stdio.h>
3 int fred(int p)
5 printf("yo %d\n", p);
6 return 42;
9 int (*f)(int) = &fred;
11 /* To test what this is supposed to test the destination function
12 (fprint here) must not be called directly anywhere in the test. */
13 int (*fprintfptr)(FILE *, const char *, ...) = &fprintf;
15 typedef int (*func) (int);
16 static int dummy1(int i) { return 0; }
17 int dummy2(int i) { return 0; }
18 static func allfunc[] = { putchar, dummy1, dummy2 };
20 int main()
22 fprintfptr(stdout, "%d\n", (*f)(24));
24 printf ("%d\n", allfunc[0] == putchar);
25 printf ("%d\n", allfunc[1] == dummy1);
26 printf ("%d\n", allfunc[2] == dummy2);
27 return 0;
30 /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/