OS X C types - was Re: is there any word processing software for the pdp11?
Toby Thain
toby at telegraphics.com.au
Thu Dec 4 21:25:55 CST 2014
On 04/12/14 6:38 PM, Peter Corlett wrote:
> On Thu, Dec 04, 2014 at 02:21:50PM -0800, Guy Sotomayor wrote:
>> On Dec 4, 2014, at 1:50 PM, Peter Corlett <abuse at cabal.org.uk> wrote:
> [...]
>>> So on systems where sizeof(int) <= sizeof(int32_t) -- which is everything
>>> that matters
>> Really? Where have you been? OS X the default has been to compile for
>> 64-bits in which case sizeof(int) == sizeof(int64_t) since Leopard (10.5) in
Maybe not:
g5:~ toby$ cc -o test test.c
g5:~ toby$ ./test
sizeof(int) = 4
g5:~ toby$ uname -a
Darwin g5 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:57:01 PDT
2009; root:xnu-1228.15.4~1/RELEASE_PPC Power Macintosh
--Toby
>> 2009. The kernel went default 64-bits in Snow Leopard (10.6) in 2010. OS X
>> on x86 has always supported mixed 32/64 bit applications (as long as the CPU
>> did) regardless of what the kernel was (a 32-bit kernel could run 64-bit
>> applications).
>
> Sorry, but you're wrong:
>
> $ clang --version
> Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
> Target: x86_64-apple-darwin13.4.0
> Thread model: posix
>
> $ cat sizeof.c
> #include <stdio.h>
> int main(void) {
> printf("sizeof(int) == %lu\n", sizeof(int));
> return 0;
> }
>
> $ clang -m64 -Wall sizeof.c && ./a.out
> sizeof(int) == 4
>
> The width of a *pointer* matches the architecture, 32 bits for i386 and 64 for
> x86_64, but the width of an *int* remains 32 bits for compatibility and
> performance reasons. The 64 bit integer type is called "long long" on both
> architectures. Obviously, one should use the typedefs in <inttypes.h> if a
> specific width integer is required, even if only to document intent.
>
> Have a look at the SysV ABI at http://www.x86-64.org/documentation.html for far
> too much gory detail and prime pedant material.
>
>
More information about the cctalk
mailing list