I noticed that UInt32 is defined differently based on the platform in MacTypes.h
#if __LP64__
typedef unsigned int UInt32;
typedef signed int SInt32;
#else
typedef unsigned long UInt32;
typedef signed long SInt32;
#endif
If unsigned int is always 32 bits on 32 and 64bit machines, why do they bother conditionally checking the platform?
The type UInt32 existed before 64-bit support. It has historically been defined as unsigned long. It could have been unsigned int. I don't know why long was chosen over int at that time. The choice would have been largely arbitrary.
Once that choice was made, though, it can't be changed, even though unsigned int would work for both 32- and 64-bit.
The big thing that would break if it were changed would be C++. In C++, the types of arguments are baked into the symbol names in the object files and libraries. long and int are different types, so void foo(long); and void foo(int); are separate functions with separate symbol names. If UInt32 were to change in 32-bit, then you wouldn't be able to link against libraries that were built with the old definition. If the libraries were rebuilt with the new definition, then old compiled code would not be able to load them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With