Date: Sun, 23 Sep 2001 10:49:28 -0700 From: Bakul Shah <bakul@bitblocks.com> To: Bruce Evans <bde@zeta.org.au> Cc: Murray Stokely <murray@FreeBSD.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/usr.sbin/sysinstall command.c config.c Message-ID: <200109231749.NAA01962@glatton.cnchost.com> In-Reply-To: Your message of "Sun, 23 Sep 2001 18:06:02 %2B1000." <20010923180124.I13390-100000@delplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> > 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. At any rate %p is preferable to %x or %lx even if not properly pedantic. I have used machines with segmented address space (an NEC unix machine in mid80s though I forget the model number) where %p would give you <seg>:<addr> but %x or %lx would be wrong. 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?200109231749.NAA01962>