🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #150

Re: Question about ANSI-C

#150
From: Shankar Unni
Date: Tue, 11 Aug 1992 21:02
29 lines
1443 bytes
In article <1992Aug10.204928.14917@frog.CRDS.COM> miket@frog.CRDS.COM (vulture) writes:

>		typedef struct prot1 {
>			int (*mycall)(char *parm1, void *parm_ptr );
>			} PRO1;
>
>		static int myfunc1 ( char *myparm1, PRO2 *ptr1 )
>			{ /* PRO2 not the same as PRO1 */
>			}
>
>		static PRO1 stuff[] = {
>			myfunc1,  /* warning: initialization type mismatch */
>			NULL
>			};

While this may seem counterintuitive at first glance, the compiler is
perfectly to complain.

Think of it this way. The prototype for (*myfunc)() is telling the
compiler that *any* type can be passed to it at a point of call. Thus,
whatever function is used to initialize (*myfunc)() should also allow
any type to be passed to it from a point of call.

Otherwise, you would end up with a situation where, at the point of
call, it is deemed to be OK to pass a type, which is not accepted at
the point of entry into the routine (i.e. a run-type type mismatch!).
--
Shankar Unni				E-Mail:	shankar@sgi.com
Silicon Graphics Inc.			Phone:	+1-415-390-2072
Technical Details
Message-ID: <oeu5t2s@fido.asd.sgi.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!dtix!darwin.sura.net!mips!odin!fido!shankar
References: <1992Aug10.204928.14917@frog.CRDS.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!dtix!darwin.sura.net!mips!odin!fido!shankar
From: shankar@sgi.com (Shankar Unni)
Newsgroups: comp.std.c
Subject: Re: Question about ANSI-C
Message-ID: <oeu5t2s@fido.asd.sgi.com>
Date: 11 Aug 92 21:02:49 GMT
References: <1992Aug10.204928.14917@frog.CRDS.COM>
Sender: news@fido.asd.sgi.com (Usenet News Admin)
Organization: Silicon Graphics, Inc.
Lines: 29