From owner-cvs-all Sun Sep 23 11:45:23 2001 Delivered-To: cvs-all@freebsd.org Received: from maile.telia.com (maile.telia.com [194.22.190.16]) by hub.freebsd.org (Postfix) with ESMTP id BA8B137B40A for ; Sun, 23 Sep 2001 11:45:18 -0700 (PDT) Received: from d1o913.telia.com (d1o913.telia.com [195.252.44.241]) by maile.telia.com (8.11.6/8.11.6) with ESMTP id f8NIjHK17118 for ; Sun, 23 Sep 2001 20:45:17 +0200 (CEST) Received: from ertr1013.student.uu.se (h185n2fls20o913.telia.com [212.181.163.185]) by d1o913.telia.com (8.8.8/8.8.8) with SMTP id UAA26995 for ; Sun, 23 Sep 2001 20:45:16 +0200 (CEST) Received: (qmail 49112 invoked by uid 1001); 23 Sep 2001 18:45:14 -0000 Date: Sun, 23 Sep 2001 20:45:14 +0200 From: Erik Trulsson To: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/usr.sbin/sysinstall command.c config.c Message-ID: <20010923204513.A48432@student.uu.se> Mail-Followup-To: cvs-all@FreeBSD.org References: <20010923180124.I13390-100000@delplex.bde.org> <200109231749.NAA01962@glatton.cnchost.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200109231749.NAA01962@glatton.cnchost.com> User-Agent: Mutt/1.3.22.1i Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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. -- Erik Trulsson ertr1013@student.uu.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message