Sender: nate AT cartsys DOT com Message-ID: <358EBF59.DAC4952C@cartsys.com> Date: Mon, 22 Jun 1998 13:32:25 -0700 From: Nate Eldredge MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: Casting void pointers References: <6mkaos$k7o AT dfw-ixnews6 DOT ix DOT netcom DOT com> <6mkfnv$hcr AT espresso DOT cafe DOT net> <358DECE1 DOT 67C137A4 AT alcyone DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Erik Max Francis wrote: > > Kaz Kylheku wrote: > > > You can create a typedef name for the function pointer and then use > > the parenthesized typedef name. Or you can write cast expressions > > like: > > > > void *q = 0; > > double (*p)(double, int) = (double (*)(double, int)) q; > > I think the original poster was really looking for the answer to the > question: For a given declaration, how do I determine its type (for > casting)? > > The answer is that if you remove the identifier name from the > declaration, that's the type. So in the declaration int p, int is the > type; in the declaration char *s, char * is the type, and in the > declaration double (*p)(double, int), double (*)(double, int) is the > type, even though it looks a little strange. #ifdef PLUG I'd like to mention that I have ported a program called `cdecl', whose job it is to covert casts, declarations, etc., to and from readable English. You can find it at my web site: http://www.cartsys.com/eldredge/ #endif -- Nate Eldredge nate AT cartsys DOT com