jeans chen
we've got them by the balls

 

linux gcc 区分32位或64位编译

 

Linux系统下程序如何区分是64位系统还是32位系统

经过对include的翻查,最后确定gcc__i386__来 进行32位编码,而以__x86_64__来进行64位编 码;64位的gentoo下stdio.h就是个简单例子(i不晓得其它的是不是?);而且在bits/wordsize.h中对这两个定义进行了综合, 以__WORDSIZE的值来表示机器类型,大家可以直接去看看

例子

#include <stdio.h>

int main(int argc  ,char* argv)

{

   #ifdef __x86_64__

        printf("__x86_64__");

   #elif __i386__

        printf("__i386__");

   #endif

   return 0;

}

 

http://cache.baiducontent.com/c?m=9d78d513d99001f04fede5697d10c0121843f0672ba6a0013894cd47c9221d03506790a63a724045c4c50b3640f9154bea876a25711e66ead993d90bc0b8992a2c8e2335741f&p=8b2a975fa49e11a05bed933a550c8d&newp=8c769a4780934eac58eacc68425e86231610db2151d2d11e29&user=baidu&fm=sc&query=arm+%B4%F3%B6%CB&qid=&p1=1

 ARM support two types. big and little

but default is little

posted on 2013-07-11 13:38  jeans chen  阅读(3231)  评论(0编辑  收藏  举报