home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.vms
- Path: sparky!uunet!mcsun!dxcern!burow
- From: burow@dxcern.cern.ch (Burkhard Burow)
- Subject: functions as arguments in DEC C
- Message-ID: <1993Jan23.211019.6955@dxcern.cern.ch>
- Organization: CERN European Laboratory for Particle Physics
- Date: Sat, 23 Jan 1993 21:10:19 GMT
- Lines: 49
-
-
- I'm having trouble passing functions as arguments on an Alpha running VMS and
- 'DEC C for OpenVMS AXP V1.2-000'
-
- 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 );
-
- Other compilers swallow line B. as is.
-
- QQQuestion: How do I force DEC C to accept line B.
- i.e. How do I cast the parameter 'a', such that it is acceptable
- as a an argument for any type of function?
- i.e. For those of you who like IQ,SAT tests and the like:
- The cast to (void *) of a pointer to an object.
- is like
- The cast to _______ of a pointer to a function.
-
- thanks,
- burkhard burow@vxdesy.cern.ch
-
- P.S My apologies to those of you who may have already caught this article in
- comp.lang.c,cern.alpha,vmsnet.alpha. A colleague spotted it there, and
- pointed out that c.o.vms might be the best place to look for an answer.
-
-