Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #144698

Re: "Conversions" of types

From David Brown <david.brown@hesbynett.no>
Newsgroups comp.lang.c
Subject Re: "Conversions" of types
Date 2019-06-10 13:24 +0200
Organization A noiseless patient Spider
Message-ID <qdlelf$ipo$1@dont-email.me> (permalink)
References <type-conversions-20190609114030@ram.dialup.fu-berlin.de> <lnsgsir42l.fsf@kst-u.example.com> <HPadnS86QeiUvWPBnZ2dnUU7-bvNnZ2d@giganews.com> <93a5e85a-bb3a-42fb-9fed-be9e73b62964@googlegroups.com>

Show all headers | View raw


On 10/06/2019 12:27, Malcolm McLean wrote:
> On Monday, 10 June 2019 10:17:10 UTC+1, unidef  wrote:
>>
>> You gotta look into the machines native assembly code to make sense out of
>> casting. I don’t know assembly that well :(
>>
> Address registers and integer registers are usually the same. So there's
> a natural mapping from int or a longer type on 64 bit machines to
> pointers and back.
> However that's not guaranteed.
> 

Fortunately, C answers the question for you.  In <stdint.h>, there will 
be types "intptr_t" and "uintptr_t" that are integer types suitable for 
mapping back and forth with pointers, unless you have such an unusual 
architecture that there are no suitable integer types.


Instead of guessing about the size of address and integer registers 
(which vary from cpu to cpu) or the relative sizes of different C 
integer types and pointers, use the /standard/ types "intptr_t" or 
"uintptr_t".

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: "Conversions" of types Keith Thompson <kst-u@mib.org> - 2019-06-09 11:44 -0700
  Re: "Conversions" of types unidef <jon@unidef-systems.com> - 2019-06-10 04:16 -0500
    Re: "Conversions" of types Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2019-06-10 03:27 -0700
      Re: "Conversions" of types David Brown <david.brown@hesbynett.no> - 2019-06-10 13:24 +0200
    Re: "Conversions" of types Keith Thompson <kst-u@mib.org> - 2019-06-10 14:00 -0700

csiph-web