*BSD News Article 84408


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!su-news-hub1.bbnplanet.com!su-news-feed4.bbnplanet.com!netapp.com!netapp.com!not-for-mail
From: guy@netapp.com (Guy Harris)
Newsgroups: comp.unix.solaris,comp.unix.bsd.misc,comp.unix.internals
Subject: Re: Solaris 2.6
Date: 6 Dec 1996 17:04:36 -0800
Organization: Network Appliance
Lines: 18
Distribution: inet
Message-ID: <58afr4$hrj@tooting.netapp.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>
NNTP-Posting-Host: tooting.netapp.com
Xref: euryale.cc.adfa.oz.au comp.unix.solaris:91674 comp.unix.bsd.misc:1713 comp.unix.internals:11494

Andrew Gabriel <andrew@cucumber.demon.co.uk> wrote:
>Out of curiosity, how would you print a pointer (for debugging say)?

How portable do you want?

On any system on which you have a conforming hosted implementation of
ANSI C,

	printf("pointer = %p\n", ptr);

works.  It even works on some systems where you *don't* have a
conforming hosted implementation of ANSI C; "%p" appears to print
pointer values even on Solaris *1*.x.

There are probably other systems on which it doesn't work, though. 
Whether those systems are a target for the code you're writing is
another matter; there are probably some people who need to make their
code run on those old moldy systems, and others who don't.