*BSD News Article 85127


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.wildstar.net!news.ececs.uc.edu!news.kei.com!news.texas.net!www.nntp.primenet.com!nntp.primenet.com!su-news-hub1.bbnplanet.com!news.bbnplanet.com!cam-news-hub1.bbnplanet.com!cam-news-feed2.bbnplanet.com!cambridge-news.cygnus.com!not-for-mail
From: meissner@cygnus.com (Michael Meissner)
Newsgroups: comp.unix.solaris,comp.unix.bsd.misc,comp.unix.internals
Subject: Re: Solaris 2.6
Date: 11 Dec 1996 13:39:31 -0500
Organization: Cygnus Support
Lines: 22
Distribution: inet
Message-ID: <sylob50vto.fsf@tiktok.cygnus.com>
References: <32986299.AC7@mail.esrin.esa.it> <casper.329d5a07@mail.fwi.uva.nl>
	<5869r2$175$1@asgard.sprintlink.co.za>
	<587mc1$1dc@cucumber.demon.co.uk> <589rd5$i2l@agate.berkeley.edu>
NNTP-Posting-Host: tiktok.cygnus.com
In-reply-to: alanc@godzilla.eecs.berkeley.edu's message of 6 Dec 1996 19:15:49
	GMT
X-Newsreader: Gnus v5.1
Xref: euryale.cc.adfa.oz.au comp.unix.solaris:92195 comp.unix.bsd.misc:1768 comp.unix.internals:11564

In article <589rd5$i2l@agate.berkeley.edu> alanc@godzilla.eecs.berkeley.edu
(Alan Coopersmith) writes:

| andrew@cucumber.demon.co.uk (Andrew Gabriel) writes in comp.unix.solaris:
| |Out of curiosity, how would you print a pointer (for debugging say)?
| |printf("pointer = 0x%lx", (long) ptr);
| |How should it be done portably?
| 
| According to my copy of the ANSI C standard, "%p" is the format
| specifier for printing pointers (the exact output format is
| implementation defined though so you're not guaranteed hex or decimal).

Not quite.  %p is for printing void * pointers.  It is only guaranteed that
void * pointers use the same size and format as char * pointers.  All other
pointers do not have to be the same size and/or format (and since I'm the one
that wrote the %p proposal in the first place, and at the time I was supporting
a C compiler that had different pointer formats, it was intentional that it be
only void * pointers).
-- 
Michael Meissner, Cygnus Support (East Coast)
4th floor, 955 Massachusetts Avenue, Cambridge, MA 02139, USA
meissner@cygnus.com,	617-354-5416 (office),	617-354-7161 (fax)