Elegant and safe way to determine if architecture is 32bit or 64bit

后端 未结 7 1512
北恋
北恋 2021-01-19 01:47

As title says, is there any elegant and safe way to determine if architecture is 32bit or 64bit. By elegant, you can think of precise, correct, short, clean, and smart way.

相关标签:
7条回答
  • 2021-01-19 02:32

    32-bit on the code bank or 32-bit on the data bank. :-) 8086 processors had 16-bit data with 20-bit code memory. Also, modern Havard machines do odd things with code/data separation...

    You might check the cpuid instruction for x86 processors. Other processor families may not have such an instruction...YMMV.

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