home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:20165 vmsnet.alpha:148 cern.alpha:33
- Newsgroups: comp.lang.c,vmsnet.alpha,cern.alpha
- Path: sparky!uunet!mcsun!sunic!kth.se!news.kth.se!LEVITTE
- From: LEVITTE@e.kth.se (Richard Levitte)
- Subject: Re: function arg.'s in Alpha's DEC C
- In-Reply-To: burow@dxcern.cern.ch's message of Sat, 23 Jan 1993 19:41:39 GMT
- Message-ID: <LEVITTE.93Jan25113221@elin.e.kth.se>
- Sender: usenet@kth.se (Usenet)
- Nntp-Posting-Host: elin.e.kth.se
- Organization: Department of TeleTransmission Theory
- References: <1993Jan23.194139.17196@dxcern.cern.ch>
- Date: Mon, 25 Jan 1993 10:32:21 GMT
- Lines: 51
-
- >>>>> On Sat, 23 Jan 1993 19:41:39 GMT, burow@dxcern.cern.ch (Burkhard Burow) said:
-
- There's some trouble with this:
-
- BB> Simplified e.g.
-
- BB> void q ( int (*c)() ); /* A. prototype of q */
-
- BB> void __q( void ( *a)() ) /* B. function with a function as argument */
- BB> {
- BB> q( a ); /* C. pass the function parameter on to q. */
- BB> }
-
- BB> For which the C compiler complains:
-
- BB> q( a );
- BB> ^
- BB> %CC-E-PASNOTREFCOM, In this statement, the referenced type of the pointer value
- BB> "a" is "Function (...) returning void", which is not compatible with "Function (
- BB> ...) returning signed int".
- BB> at line number 5
-
-
- BB has tried this cast:
-
- BB> q( *(void **)&a );
-
- I very surprised that cast worked...
-
- BB> Other compilers swallow line B. as is.
-
- IMHO, those compilers are wrong!
-
- A working cast should be:
-
- q( (int (*)())a);
-
- The best, though, would be to make the return types compatible. Why on
- earth do you want to give q() a function returning nothing when it
- expects a function returning int???? What if q() tries to use that
- returned (void) integer?
-
- IMHO, there's a design problem here... or just a bug.
-
- --
- !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
- ! Richard Levitte, VMS GNU Emacs hacker ! tel: int+46-8-18 30 99 !
- ! Sulv"agen 57, II ! fax: none for the moment !
- ! S-126 40 H"agersten ! Internet: levitte@e.kth.se !
- ! SWEDEN ! !
- !-----------------------------------------------------------------------------!
-