How to check if your app is running in 64bit

- by

There are two ways to determine this: at runtime (i.e. in your running code), and at compile time (i.e. before the code is compiled). Let’s take a look at both options.

Runtime Check

// testing for 64bit at runtime
    
    if (sizeof(void*) == 4) {
        self.textLabel.text = @"You're running in 32 bit";
        
    } else if (sizeof(void*) == 8) {
        self.textLabel.text = @"You're running in 64 bit";
    }

Determines the size of a pointer.

Compile Time Check

#if __LP64__
    // you're running 64bit
#else
    // you're running 32bit
#endif

Asks the compiler which architecture it compiles for.



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.