Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
569 views
in Technique[技术] by (71.8m points)

arm - What predefined macro can I use to detect the target architecture in Clang?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...