How to check if your app is running in 64bit

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.





Leave a Reply