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.





Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.