home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lclint.zip / lclint-2_3h-os2-bin.zip / test / csyntax16.c < prev    next >
C/C++ Source or Header  |  1997-09-03  |  950b  |  49 lines

  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.  
  49.