size of machine 64 or 32 bit

前端 未结 6 867
一整个雨季
一整个雨季 2021-02-15 17:32

If I am working on a Unix machine, how could I know the size of the machine whether it is 64-bit or 32-bit machine?

相关标签:
6条回答
  • 2021-02-15 18:19

    If you're just looking to check the architecture of a machine you're on,

      %> uname -a
    

    from the command line usually contains an indication in the output.

    0 讨论(0)
  • 2021-02-15 18:20

    You can also try sizeof(int *). Should be 4 on 32 bit machines and 8 on 64 bit machines.

    0 讨论(0)
  • 2021-02-15 18:29

    You can type

    uname -m 
    

    if i686 or i386 is appearing, you are working with 32 bit if X86_64 is appearing, you are working with 64 bit

    0 讨论(0)
  • 2021-02-15 18:30

    Assuming you want to do this at compile time - take a look here for architecture macros you can test. You are probably looking for __x86_64__.

    0 讨论(0)
  • 2021-02-15 18:31

    AIX you can do this:

    getconf KERNEL_BITMODE
    

    HP-UX you can do this:

    getconf KERNEL_BITS
    

    or just:

    getconf -a | grep KERN
    

    Sun Solaris you can do this:

    isainfo -v
    

    For Linux, yes, the uname -a should do the trick

    0 讨论(0)
  • 2021-02-15 18:31

    I have to deal with a lot of Unix platforms and generally the best way I have found is to look at the output of "uname -a". For example, if you see something like "i686 i686 i386 GNU/Linux" in the output you know it's a 32 bit machine. If "amd64" shows up it's a 64. Sometimes it's a matter of trying to run a 64 bit programme. Sometimes it's RTFM.

    0 讨论(0)
提交回复
热议问题