home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20123 < prev    next >
Encoding:
Internet Message Format  |  1993-01-22  |  1.6 KB

  1. Xref: sparky comp.lang.c:20123 vmsnet.alpha:137 cern.alpha:30
  2. Newsgroups: comp.lang.c,vmsnet.alpha,cern.alpha
  3. Path: sparky!uunet!spool.mu.edu!agate!overload.lbl.gov!dxcern!burow
  4. From: burow@dxcern.cern.ch (Burkhard Burow)
  5. Subject: function arg.'s in Alpha's DEC C
  6. Message-ID: <1993Jan23.194139.17196@dxcern.cern.ch>
  7. Organization: CERN European Laboratory for Particle Physics
  8. Date: Sat, 23 Jan 1993 19:41:39 GMT
  9. Lines: 40
  10.  
  11.  
  12. I'm having trouble passing functions as arguments on an Alpha running VMS and
  13. 'DEC C for OpenVMS AXP V1.2-000'
  14.  
  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. Other compilers swallow line B. as is.
  44.  
  45. QQQuestion: How do I force DEC C to accept line B.
  46.             i.e. How do I cast the parameter 'a', such that it is acceptable
  47.                  as a an argument for any type of function?
  48.  
  49. thanks,
  50. burkhard      burow@vxdesy.cern.ch
  51.