Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Sep 2001 20:45:14 +0200
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/usr.sbin/sysinstall command.c config.c
Message-ID:  <20010923204513.A48432@student.uu.se>
In-Reply-To: <200109231749.NAA01962@glatton.cnchost.com>
References:  <20010923180124.I13390-100000@delplex.bde.org> <200109231749.NAA01962@glatton.cnchost.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Sep 23, 2001 at 10:49:28AM -0700, Bakul Shah wrote:
> > >     Use '%p' when printing out the address of a function.
> > >     sizeof(int) != sizeof(long)
> > 
> > %p is for printing pointers of type "void *".  It is unsuitable for
> > printing arbitrary pointers to objects.  It is especially unsuitable
> > for printing pointers to functions.
> 
> I have an old (1997) working draft of C9X which says
> 
>     6.2.2.3  Pointers
> 
> 	   [#1] A pointer to void may be converted to or from a pointer
> 	   to  any  incomplete  or  object  type.   A  pointer  to  any
> 	   incomplete or object type may be converted to a  pointer  to
> 	   void  and  back again; the result shall compare equal to the
> 	   original pointer.
> 
> Since any object ptr may be converted to %p, you can do, e.g.
> 
> 	printf("...%p...", ..., (void*)&some_function, ...);
> 
> But you seem to be saying this is not be a valid conversion.
> Have things changed since then or is a function not
> considered an "object"?  I would appreciate a C standard
> reference ( i.e. chapter and verse!) that shows this is
> invalid.

In general function pointers cannot be converted to/from non-function
pointers.
Functions are indeed not considered objects.
In a somewhat more recent (Jan 1999) draft of C9X 'object' is defined
as follows:

     3.15
     [#1] object
     region of data storage in  the  execution  environment,  the
     contents of which can represent values
     [#2]  NOTE  When referenced, an object may be interpreted as
     having a particular type; see 6.3.2.1.





-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010923204513.A48432>