0

How to tell if my compiled C++ macOS app is running on AMR64 vs Intel x86-64 architecture?

PS. I need this for logging purposes.

c00000fd
  • 20,994
  • 29
  • 177
  • 400
  • since you need two different compile runs for these two different targets, you can just as well already detect that at compile. The link I shared above explains how. – Marcus Müller Apr 26 '23 at 18:59
  • Are you looking for a bit of magic you can pull after the fact? As in you can't simply build in a function that tells you? – user4581301 Apr 26 '23 at 19:01
  • Hint: The platform information is either supplied to the compiler; or it is already known by the compiler. So why not ask the compiler by checking predefined macros? – Thomas Matthews Apr 26 '23 at 20:55
  • @ThomasMatthews that's what I was asking. Xcode and Mach-O file format supports binaries with dual architectures, so I wanted to know which one my compiled code is running under. So it seems like for Xcode `#if defined(__x86_64__) || defined(i386)` will mean x86 and `#elif defined(__aarch64__)` will mean ARM64. – c00000fd Apr 26 '23 at 21:59

0 Answers0