Re: main function address

From: Arthur J. O'Dwyer (ajo_at_nospam.andrew.cmu.edu)
Date: 04/07/04


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



Relevant Pages

  • Re: Procedure Pointer (Components) with no explicit interface and with implicit typing
    ... in principle, I can assign to it either a function nor a subroutine, e.g. ... "7.4.2.2 Procedure pointer assignment" ... "If proc-pointer-object has an implicit interface and is explicitly ... external:: func, sub ...
    (comp.lang.fortran)
  • Re: Pointer-valued function to access inner components
    ... implicit none ... Return a F90 pointer which points to the diagonal of T. ... a copyin/copyout on array A during the procedure call. ... subroutine dirty_pointer_1d ...
    (comp.lang.fortran)
  • Re: Problem using string pointer
    ... can implicitely be converted into a non-const ... pointer, but the conversion is deprecated and ... you did by using the implicit cast above), ...
    (microsoft.public.vc.language)
  • Re: Banks and economy
    ... then there is no space allocation for the ... pointer type - which I think is correct for "arrays", ... implicit allocation of a byte. ... It is an incomplete type of type array of char. ...
    (alt.lang.asm)
  • Re: Question about OO programming in Ada
    ... specific to class-wide pointer is implicit. ... You can allocate items, nodes in your own storage pools. ...
    (comp.lang.ada)