检查应用程序是以32位还是64位构建? [英] Check if app is built in 32 or 64-bit?

查看:153
本文介绍了检查应用程序是以32位还是64位构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查我的应用程序是以32位还是64位编译?

How can I check whether my app is compiled in 32-bit or 64-bit ?

这有助于调试低级代码(例如使用缓冲区) )。

This is helpful to debug low level code (working with buffers for example).

推荐答案

编译时检查将涉及 #ifdef 'ing对于 __ LP64 __ ,这是ARM的数据类型大小标准。运行时解决方案将涉及检查指针的大小,如下所示:

A compile time check would involve #ifdef'ing for __LP64__, which is ARM's data type size standard. A runtime solution would involve checking the size of pointers, like so:

if (sizeof(void*) == 4) {
    // Executing in a 32-bit environment
} else if (sizeof(void*) == 8) {
   // Executing in a 64-bit environment
}

值得庆幸的是,指针大小是编译64位代码的不同标准似乎同意的一件事。

Thankfully, pointer sizes are the one thing that the different standards for compiling 64-bit code seem to agree on.

这篇关于检查应用程序是以32位还是64位构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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