标 题: Re: [求助]如何获得CPU字长,是32bit还是64bit的?
发信站: 北邮人论坛 (Fri Apr 23 12:54:56 2010), 站内
int cpu_bits(void *dummy1, void *dummy2)
{
long offset = (long)&dummy2 - (long)&dummy1;
int ret = 0;
if (8 == offset)
ret = 64;
else if (4 == offset)
ret = 32;
else if (2 == offset)
ret = 16;
else if (1 == offset)
ret = 8;
else
ret = -1;
return ret;
}
int main()
{
printf("%d\n", cpu_bits(NULL, NULL));
return 0;
}
阅读(1918) | 评论(0) | 转发(0) |