Re: main function address
From: Arthur J. O'Dwyer (ajo_at_nospam.andrew.cmu.edu)
Date: 04/07/04
- Next message: Eric Sosman: "Re: use delete to destroy primitive/object types but memory is not freed"
- Previous message: Ike Naar: "Re: pointer-in-array test"
- In reply to: Leor Zolman: "Re: main function address"
- Next in thread: Leor Zolman: "Re: main function address"
- Reply: Leor Zolman: "Re: main function address"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 7 Apr 2004 16:04:10 -0400 (EDT)
On Wed, 7 Apr 2004, Leor Zolman wrote:
>
> Curious -- I've never considered how implicit conversion rules ought to
> play out in the arena of variadic functions... on one hand, pointers to
> /anything/ implicitly convert to pointer-to-void, but on the other hand
> there's no declaration for the receiving pointer-to-void.
>
> Or, does the implicit conversion apply when the pointer value is extracted
> and cast to void * in the receiving function?
I don't understand what you mean. Pointer-to-foo and pointer-to-void
can be implicitly "inter-converted" like this:
foo *pf;
void *pv;
pf = pv; pv = pf;
Likewise, 'pf' passed to a function prototyped as expecting a void
pointer will be implicitly converted. And vice versa.
Variadic functions are by definition not prototyped as expecting
anything in particular in the "..." part. So when you have
printf("foo", pf);
the value of 'pf' is passed to 'printf' as a pointer to foo, no
matter what the function actually expects. Likewise, in
printf("foo", pv);
'pv' is passed as a pointer to void.
Does that clear up your doubts?
HTH,
-Arthur
- Next message: Eric Sosman: "Re: use delete to destroy primitive/object types but memory is not freed"
- Previous message: Ike Naar: "Re: pointer-in-array test"
- In reply to: Leor Zolman: "Re: main function address"
- Next in thread: Leor Zolman: "Re: main function address"
- Reply: Leor Zolman: "Re: main function address"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|