home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / vms / 21852 < prev    next >
Encoding:
Internet Message Format  |  1993-01-24  |  2.3 KB

  1. Path: sparky!uunet!usc!elroy.jpl.nasa.gov!nntp-server.caltech.edu!SOL1.GPS.CALTECH.EDU!CARL
  2. From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
  3. Newsgroups: comp.os.vms
  4. Subject: Re: functions as arguments in DEC C
  5. Date: 23 Jan 1993 22:39:34 GMT
  6. Organization: HST Wide Field/Planetary Camera
  7. Lines: 42
  8. Distribution: world
  9. Message-ID: <1jshf6INNgce@gap.caltech.edu>
  10. References: <1993Jan23.211019.6955@dxcern.cern.ch>
  11. Reply-To: carl@SOL1.GPS.CALTECH.EDU
  12. NNTP-Posting-Host: sol1.gps.caltech.edu
  13.  
  14. In article <1993Jan23.211019.6955@dxcern.cern.ch>, burow@dxcern.cern.ch (Burkhard Burow) writes:
  15. =My application generates 'wrapper' routines which pass along functions to
  16. =other routines. The wrapper routines do not know the type of the functions they
  17. =are passing along.
  18. =
  19. =Simplified e.g.
  20. =
  21. =void q ( int (*c)() );     /* A. prototype of q                              */
  22. =
  23. =void __q( void ( *a)() )   /* B. function with a function as argument        */
  24. ={
  25. =q( a );                    /* C. pass the function parameter on to q.        */
  26. =}
  27. =
  28. =For which the C compiler complains:
  29. =
  30. =q( a );
  31. =^
  32. =%CC-E-PASNOTREFCOM, In this statement, the referenced type of the pointer value
  33. ="a" is "Function (...) returning void", which is not compatible with "Function (
  34. =...) returning signed int".
  35. =at line number 5
  36. =
  37. =
  38. =Silicon Graphics 2.0.1 ANSI generates a similar warning, but can be satisfied
  39. =by casting 'a' in line B. as follows:
  40. =
  41. =q( *(void **)&a );        
  42.  
  43. Well, if you want to cast a as a signed int (which is what the error message
  44. told you, and your declaration implies, the function q requires as an argument),
  45. you don't use "*(void **) &a", you use "*(int **) &a".  Have you tried that?
  46. Note:  Since I don't have DEC C, this is just a guess, based on what you've
  47. told us, and the fact that VAX C accepts the syntax I've suggested.
  48. --------------------------------------------------------------------------------
  49. Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL
  50.  
  51. Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
  52. understanding of astronomy is purely at the amateur level (or below).  So
  53. unless what I'm saying is directly related to VAX/VMS, don't hold me or my
  54. organization responsible for it.  If it IS related to VAX/VMS, you can try to
  55. hold me responsible for it, but my organization had nothing to do with it.
  56.