• 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: wrong value for LONG_MAX (9223372036854775807 rather than 2147483647) on macintosh 10.6 ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wrong value for LONG_MAX (9223372036854775807 rather than 2147483647) on macintosh 10.6 ?


  • Subject: Re: wrong value for LONG_MAX (9223372036854775807 rather than 2147483647) on macintosh 10.6 ?
  • From: "Sean McBride" <email@hidden>
  • Date: Thu, 3 Dec 2009 19:17:07 -0500
  • Organization: Rogue Research Inc.

On 12/3/09 7:11 PM, CSights said:

>	It appears that on macintosh 10.6 LONG_MAX has the same value as LLONG_MAX
>(both are 9223372036854775807).
>	According to http://home.att.net/~jackklein/c/inttypes.html#problems
>LONG_MAX should be 2147483647.
>	Some version info:
>$ g++ --version
>i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5646) (dot 1)
>$ uname -a
>Darwin xxxxxxxxxxxxxxxxxxxxxx 10.2.0 Darwin Kernel Version 10.2.0:
>Tue Nov  3 10:37:10 PST 2009; root:xnu-1486.2.11~1/RELEASE_I386 i386
>
>Below is a program that demonstrates this:
>
>$ cat long_max.cpp
>#include <iostream>
>#include <climits>
>
>int main()
>{
>        std::cout << "LONG_MIN="<<LONG_MIN<<"\n";
>        std::cout << "LONG_MAX="<<LONG_MAX<<"\n";
>        std::cout << "LLONG_MIN="<<LLONG_MIN<<"\n";
>        std::cout << "LLONG_MAX="<<LLONG_MAX<<"\n";
>}
>
>$ ./a.out
>LONG_MIN=-9223372036854775808
>LONG_MAX=9223372036854775807
>LLONG_MIN=-9223372036854775808
>LLONG_MAX=9223372036854775807
>
>Is this right?

Yes.

Which compiler flags did you use?  If none, then on 10.6 you get a 64
bit build.  With the 64 bit ABI, long is a 64 bit value.  See:
<http://developer.apple.com/mac/library/DOCUMENTATION/Darwin/Conceptual/
64bitPorting/transition/transition.html#//apple_ref/doc/uid/TP40001064-
CH207-TPXREF101>

If you want a value of an exact size, use int32_t, uint64_t, etc.  The C
language does not guarantee that 'long' (or other basic types) are an
exact size.

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


 _______________________________________________
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: wrong value for LONG_MAX (9223372036854775807 rather than 2147483647) on macintosh 10.6 ?
      • From: Rippit the Ogg Frog <email@hidden>
References: 
 >wrong value for LONG_MAX (9223372036854775807 rather than 2147483647) on macintosh 10.6 ? (From: CSights <email@hidden>)

  • Prev by Date: Re: wrong value for LONG_MAX (9223372036854775807 rather than 2147483647) on macintosh 10.6 ?
  • Next by Date: Re: wrong value for LONG_MAX (9223372036854775807 rather than 2147483647) on macintosh 10.6 ?
  • Previous by thread: Re: wrong value for LONG_MAX (9223372036854775807 rather than 2147483647) on macintosh 10.6 ?
  • Next by thread: Re: wrong value for LONG_MAX (9223372036854775807 rather than 2147483647) on macintosh 10.6 ?
  • Index(es):
    • Date
    • Thread