home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18375 < prev    next >
Encoding:
Internet Message Format  |  1992-12-15  |  1.0 KB

  1. From: curry@hplred.HPL.HP.COM (Bo Curry)
  2. Date: Tue, 15 Dec 1992 02:21:58 GMT
  3. Subject: Pointer to Function Question
  4. Message-ID: <1000001@hplred.HPL.HP.COM>
  5. Organization: Hewlett-Packard Laboratories, Palo Alto, CA
  6. Path: sparky!uunet!usc!sdd.hp.com!apollo.hp.com!cupnews0.cup.hp.com!hpscit.sc.hp.com!hplextra!hplred!curry
  7. Newsgroups: comp.lang.c
  8. Lines: 29
  9.  
  10. I have a pointer-to-function question which is baffling me. Perhaps one
  11. of the gurus out there has the answer?
  12.  
  13. typedef struct {
  14.     void (* displayit)(struct _WINDOW *);
  15. } DISPLAYTYPE;
  16.  
  17. static void ShowMyPanes(struct _WINDOW *);
  18.  
  19. int Testit ()
  20. {
  21.     DISPLAYTYPE mypanes;
  22.  
  23.     mypanes.displayit= ShowMyPanes;
  24.         
  25.     ...
  26. }
  27.  
  28. My compilers, both the HPUX ANSI c89 (8.54) and Microsoft 7.0, complain that
  29. the "Pointers are not assignment-compatible". The code seems correct, and
  30. works OK. If the argument of the assigned function is int, or (void *),
  31. they don't complain, only if it is (struct x *).
  32.  
  33. Any advice, explanations, or gentle instruction would be appreciated.
  34.  
  35. Thanks,
  36.  
  37. Bo Curry
  38. curry@hplabs.hpl.hp.com
  39.