#include <stdio.h>
#include <assert.h>
// 获取程序位数(被编译为多少位的代码)
int GetProgramBits()
{
return sizeof(int*) * 8;
}
int main(int argc, char* argv[])
{
printf("bits:\t%d\n", GetProgramBits());
assert( argc>1 );
return 0;
#include <assert.h>
// 获取程序位数(被编译为多少位的代码)
int GetProgramBits()
{
return sizeof(int*) * 8;
}
int main(int argc, char* argv[])
{
printf("bits:\t%d\n", GetProgramBits());
assert( argc>1 );
return 0;
}
-------------------------------------------
(a) compile 64 bit program
gcc -c test_code.c
gcc -o program.exe test_code.o
(b) compile 64 bit program
gcc -m64 -c test_code.c
gcc -m64 -o program.exe test_code.o
(c) compile 32 bit program
gcc -m32 -c test_code.c
gcc -m32 -o program.exe test_code.o
-------------
run the program:
./program.exe
then you will see if the compiled result is 32 or 64
--------------======
To check a file is 32bit or 64 bit,
open the exe file by nodepad++, in line2 or line3,
"L" == 32 bit
"d" == 64 bit