Get CPU Arch

I feel like this is a dumb question… but how do I determine if my app is running on ARM64 or x64?

I compile it for different platforms, so need to determine with code during app start. I’d rather not parse “uname” output if possible!

If you happen to have MBS plugins, you can use SystemInformationMBS.isARM

I don’t, am trying to do it natively

#if TargetARM then
  // https://documentation.xojo.com/api/compiler_directives/targetarm.html

#elseif TargetX86 then
  // https://documentation.xojo.com/api/compiler_directives/targetx86.html

#endif
2 Likes

There is one issue with that Tim. You can’t tell if it’s an Intel binary running on an arm machine that way.

You could however use a shell command:

uname -m

Which should return arm64 or x86_64

Agreed, however OP mentioned

I’d rather not parse “uname” output if possible!

and doesn’t want to use plugins so options are becoming thin :man_shrugging:

1 Like

I knew it was a dumb question! I use TargetLinux / TargetWindows all the time.

Thank you

my use case is ARM binary on ARM, i am trying to keep a shared codebase throughout so will just run my check during start.

Is that true for all of your users? Windows ARM can also run Intel apps.

FWIW, uname is also a system call so the chances of this call changing its output is probably zero:

NSString *cpuArchitecture() {
    struct utsname systemInfo;
    uname(&systemInfo);
    return [NSString stringWithUTF8String:systemInfo.sysname];
}
1 Like

yes, 100%