什么predefined宏我可以用它来检测锵的目标架构? [英] What predefined macro can I use to detect the target architecture in Clang?

查看:173
本文介绍了什么predefined宏我可以用它来检测锵的目标架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这取决于写code中的目标架构是如ARMv7的,armv7s或arm64。

I would like to write code depending on whether the target architecture is e.g. armv7, armv7s, or arm64.

这是我不能使用的原因<一href=\"http://stackoverflow.com/questions/19859388/how-can-i-get-the-ios-device-cpu-architecture-in-runtime\">sysctlbyname是,这会给我的底层架构在运行,但是当arm64例如模拟的ARMv7,sysctl的(貌似)仍然报告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.

推荐答案

铛--target = ... = -mcpu ... -E - -dM&LT;的/ dev / null的将输出所有的pre-定义preprocessor宏(海合会类似的作品,太)

clang --target=... -mcpu=... -E - -dM </dev/null will output all the pre-defined preprocessor macros (similar works for gcc, too)

我不明白单宏给出了答案,但你也许可以用__ ARM_ARCH 的组合规定(__ ARM_ARCH _ *)

I don't see single macro that provides the answer, but you can probably use some combination of __ARM_ARCH and defined(__ARM_ARCH_*).

这篇关于什么predefined宏我可以用它来检测锵的目标架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆