I would like to write code depending on whether the target architecture is e.g. armv7, armv7s, or arm64.
The reason that I can't use sysctlbyname is that this would give me the underlying architecture at runtime, but when arm64 e.g. simulates armv7, sysctl (seemingly) still reports arm64.
Although this is not a 100% answer to the question, but may be useful:
When using clang, you can discern between 32 bit arm and 64 bit arm using:
__arm__
which is defined for 32bit arm, and 32bit arm only.
__aarch64__
which is defined for 64bit arm, and 64bit arm only.
clang --target=... -mcpu=... -E - -dM </dev/null
will output all the pre-defined preprocessor macros (similar works for gcc, too)
I don't see single macro that provides the answer, but you can probably use some combination of __ARM_ARCH
and defined(__ARM_ARCH_*)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With