在 C 中检测 64 位编译 [英] Detecting 64bit compile in C

查看:33
本文介绍了在 C 中检测 64 位编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有 C 宏或某种方法可以检查我的 C 程序在编译时是在 C 中编译为 64 位还是 32 位?

is there a C macro or some kind of way that i can check if my c program was compiled as 64bit or 32bit at compile time in C?

编译器:GCC我需要检查的操作系统:Unix/Linux

Compiler: GCC Operating systems that i need to do the checks on: Unix/Linux

另外,如果操作系统支持 64 位,我在运行程序时如何检查?

Also how could i check when running my program if the OS is capable of 64bit?

推荐答案

既然你标记了这个gcc",试试

Since you tagged this "gcc", try

#if __x86_64__
/* 64-bit */
#endif

这篇关于在 C 中检测 64 位编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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