]>
Commit | Line | Data |
---|---|---|
885824d3 | 1 | /* |
2 | * lclfoo.c - test lclint | |
3 | */ | |
4 | ||
5 | #include <stdio.h> | |
6 | #include <stdlib.h> | |
7 | ||
8 | int main(int argc, char *argv[]) | |
9 | { | |
10 | int i = 0, num; | |
11 | float pet = 0.0; | |
12 | int (*qfun)(float *); | |
13 | ||
14 | int (*getbuiltout(int))(float *); | |
15 | ||
16 | num = (argc > 1) ? atoi(argv[1]) : 0; | |
17 | ||
18 | qfun = getbuiltout(num); | |
19 | ||
20 | if (qfun != NULL) { | |
21 | i = qfun(&pet); | |
22 | printf("number in float %f and returns %d\n", pet, i); | |
23 | exit(EXIT_SUCCESS); | |
24 | } else exit(EXIT_FAILURE); | |
25 | } | |
26 | ||
27 | /* | |
28 | * should be a function (of one arg - int) returning | |
29 | * a pointer to a function (of one arg - float *) returning int | |
30 | * | |
31 | * From: cdecl | |
32 | * cdecl> declare getbuiltout as function (verbose as int) returning | |
33 | * pointer to function (pobj as pointer to float) returning int | |
34 | * int (*getbuiltout(int verbose))(float *pobj) { } | |
35 | */ | |
36 | ||
37 | int (*getbuiltout(int verbose))(float *) | |
38 | { | |
39 | int qpolygon(float *); | |
40 | ||
41 | switch(verbose) { | |
42 | case 1: | |
43 | return qpolygon; | |
44 | default: | |
45 | return NULL; | |
46 | } | |
47 | } | |
48 |