public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@cygnus.com>
To: "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu>
Cc: rth@cygnus.com, egcs@cygnus.com
Subject: Re: Is there a HOST_BITS_PER_POINTER macro?
Date: Tue, 10 Feb 1998 03:34:00 -0000	[thread overview]
Message-ID: <19980206111407.32563@dot.cygnus.com> (raw)
In-Reply-To: <199802061648.LAA11516@caip.rutgers.edu>

On Fri, Feb 06, 1998 at 11:48:08AM -0500, Kaveh R. Ghazi wrote:
>  >   sprintf(foo, "%p", ptr)
>  >   exit (strcmp(foo, "0"));

The problem is that it is implementation defined what
format pointers are represented in.  So you might easily
get any of

	0
	00000000
	0x0
	0x00000000
	0000:0000

I can think of two possible solutions:

	char buf[64];
	sprintf (buf, "%p", buf);
#ifdef HAVE_INDEX
	exit (index (buf, 'p') == NULL);
#else
	exit (strchr (buf, 'p') == NULL);
#endif

since it seems unlikely that any representation will result in 'p',
though of course that's not the only failure mode, or
	
	char buf[64];
	char *p = buf, *q = NULL;
	sprintf(buf, "%p", p);
	sscanf(buf, "%p", &q);
	exit (p != q);

if sscanf can be trusted to read them back in.  I would think that's
required, but...


r~

  reply	other threads:[~1998-02-10  3:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-02-06  8:48 Kaveh R. Ghazi
1998-02-10  3:34 ` Richard Henderson [this message]
  -- strict thread matches above, loose matches on Subject: below --
1998-02-07 13:09 Kaveh R. Ghazi
1998-02-07 13:29 ` Richard Henderson
1998-02-05 16:45 Kaveh R. Ghazi
1998-02-05 22:09 ` Joern Rennecke
1998-02-05 22:09 ` Richard Henderson
1998-02-06  0:57   ` Jeffrey A Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19980206111407.32563@dot.cygnus.com \
    --to=rth@cygnus.com \
    --cc=egcs@cygnus.com \
    --cc=ghazi@caip.rutgers.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).