简体   繁体   中英

Unsigned Long to support 64 bit iOS & OSX

For my iOS & OS X C++ Library, the data type unsigned long is causing problems in 64 bit environment. It works fine in 32 bit Architecture. In GCC read about -mx32 Compiler Flag, which will process all 64 bit data types as 32 bit. In iOS & OS X for llvm, does there exists any such Flags to support unsigned long as in 32 bit architecture. I have tried adding -mx32 flag in Compliter Flags section, still size of unsigned long is printed as 8.

Thanks.

The size of long is defined by the platform ABI. Apple has announced that you must support their 64-bit ABIs:

  • 64-bit Requirement for Mac Apps

    At WWDC 2017, we announced new apps submitted to the Mac App Store must support 64-bit starting January 2018, and Mac app updates and existing apps must support 64-bit starting June 2018. If you distribute your apps outside the Mac App Store, we highly recommend distributing 64-bit binaries to make sure your users can continue to run your apps on future versions of macOS. macOS High Sierra will be the last macOS release to support 32-bit apps without compromise.

  • 64-bit Apps on iOS 11

    As a reminder, new iOS apps and updates submitted to the App Store must support 64-bit. Support for 32-bit apps is not available in iOS 11 and all 32-bit apps previously installed on a user's device will not launch. If you haven't updated your app on the App Store to support 64-bit, we recommend submitting an update so your users can continue to run your apps on iOS 11, which will be in the hands of hundreds of millions of customers this fall.

This means that going back to a 32-bit only build will not work in the near term. It is theoretically possible to build a custom compiler which has a 64-bit ABI on the outside, but different type sizes on the inside. OpenJDK does this internally, and the GNU toolchain supports something quite similar on x86-64 (although it still needs kernel support, so it's not an option for Darwin). But this is a lot of work, and requires lots of adjustments to system headers.

Unfortunately, your best bet is to replace unsigned long in your software with a portable type such as uint32_t .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM