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