• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: 64 bit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 64 bit


  • Subject: Re: 64 bit
  • From: Alastair Houghton <email@hidden>
  • Date: Tue, 25 Dec 2007 00:42:32 +0000

On 24 Dec 2007, at 22:49, David Fang wrote:

Yes, I know, this reply comes awfully late, but 'twas the night before Christmas, and I'm bored in the house, catching up on mailing lists without using a mouse...

Of course this all assumes that portability is indeed a goal :-)

Sure, and it all stems from the fact that there isn't a portable 64- bit integer type in C++.


(FWIW, I wasn't paying a great deal of attention and hadn't actually noticed that he was using C++ rather than C. Also, on the <inttypes.h> point, I seem to recall reading somewhere that <inttypes.h> is supposed to be more widely deployed in practice than <stdint.h>, so maybe using the former is better for portability.)

One option is to use -m64, which results in 64b long.

In general that's an extremely bad idea. It fundamentally changes the ABI, so calling system routines (even fundamental things like the C runtime library) might not work.


This gets around having to use the pedantically rejected "long long". (ints are still 32b, pointers are 64b.)

...(and any "long" parameters to APIs you were using are going to get passed as 64-bit values when the API expects them to be 32-bit)...


If you need *exactly* 64b, look for types like "int64_t" in the system's type headers.

<inttypes.h> is probably the best place if you want portability, since it's defined by C99 but was already present on some systems prior to that. I tend to include <stdint.h> myself, but then I only care about systems with C99.


BSD also defines some similar types (in <sys/types.h>), though the unsigned variants have an additional underscore (i.e. u_int16_t versus the C99 uint16_t).

And there are some Apple types that come from Carbon (e.g. SInt32, UInt32).

Anyway, there are plenty of types to choose from. The C99 ones have the advantage of being able to specify that e.g. you want something with at least 64 bits that will be fast, or you'd like something that can hold integers and pointers.

Kind regards,

Alastair.

--
http://alastairs-place.net



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: 64 bit
      • From: David Fang <email@hidden>
References: 
 >64 bit (From: email@hidden)
 >Re: 64 bit (From: Nick Zitzmann <email@hidden>)
 >Re: 64 bit (From: Perry Winkel <email@hidden>)
 >Re: 64 bit (From: Alastair Houghton <email@hidden>)
 >Re: 64 bit (From: "Sean McBride" <email@hidden>)
 >Re: 64 bit (From: Peter O'Gorman <email@hidden>)
 >Re: 64 bit (From: Alastair Houghton <email@hidden>)
 >Re: 64 bit (From: David Fang <email@hidden>)

  • Prev by Date: Re: 64 bit
  • Next by Date: Re: 64 bit
  • Previous by thread: Re: 64 bit
  • Next by thread: Re: 64 bit
  • Index(es):
    • Date
    • Thread