All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael David Crawford <mdc@prgmr.com>
To: xen-devel@lists.xensource.com
Subject: Casting 64-bit pointers to integers
Date: Fri, 22 May 2009 02:30:35 -0700	[thread overview]
Message-ID: <4A1670BB.90101@prgmr.com> (raw)

In building on my 64-bit Xeon box, I see a lot of warnings about casting 
between pointers and integers of different sizes.

Sometimes it can cause fatal compiler error.

Is there a reasonably portable way to make such casts?

The conventional wisdom is that ints are supposed to be the natural 
machine word size.  But even that isn't always the case - much gnashing 
of teeth resulted in the two most popular compilers for the 68000 
Macintosh having different int sizes.

There are typedefs for integers with specific numbers of bits, but 
that's not what we want.  If we're building for 32-bit, we want a 32-bit 
integer, and if we're building for 64-bit, we want a 64-bit integer.

Is there any kind of standardized integer type which is guaranteed to be 
the same size as a pointer?

What might even be worse is that the mismatch is on purpose for some 
reason, say that some structure has a field that simply *must* be 
32-bits, but we're trying to wedge a 64-bit pointer into it.

Mike
-- 
Michael David Crawford
mdc@prgmr.com

    prgmr.com - We Don't Assume You Are Stupid.

       Xen-Powered Virtual Private Servers: http://prgmr.com/xen

             reply	other threads:[~2009-05-22  9:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-22  9:30 Michael David Crawford [this message]
2009-05-22  9:41 ` Casting 64-bit pointers to integers Samuel Thibault
2009-05-22  9:53   ` Michael David Crawford
2009-05-22 10:01     ` Samuel Thibault

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=4A1670BB.90101@prgmr.com \
    --to=mdc@prgmr.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.