我的团队最近一直在研究JNI,因此我们遇到了有关32位和64位架构的不同问题.我们来举个例子(temp.c).
#include
void main(){
printf("long=%d\n",sizeof(long));
}
gcc_32_bit temp.c和gcc_64_bit -m32 temp.c之间有什么区别吗?
案例测试:
案例1:使用gcc temp.c在64位ubuntu上编译的代码.输出:64位ubuntu上的long = 8.
案例2:使用gcc -m32 temp.c在64位ubuntu上编译的代码.输出:64位ubuntu上的long = 4.
案例3:使用/usr/local/gcc-4.8.1-for-linux64/bin/x86_64-pc-linux-gcc temp.c在64位MAC(64-bit cross compiler used)上编译的代码.输出:64位ubuntu上的long = 8.
案例4:使用/usr/local/gcc-4.8.1-for-linux32/bin/i586-pc-linux-gcc temp.c在64位MAC(32-bit cross compiler used)上编译的代码.输出:错误:无法在64位ubuntu上运行.
我们使用MAC交叉编译器,因为我们没有32位linux机器.