Determine word size of my processor

后端 未结 8 1259
长发绾君心
长发绾君心 2020-11-28 08:26

How do I determine the word size of my CPU? If I understand correct an int should be one word right? I\'m not sure if I am correct.

So should just prin

8条回答
  •  野性不改
    2020-11-28 09:16

    In short: There's no good way. The original idea behind the C data types was that int would be the fastest (native) integer type, long the biggest etc.

    Then came operating systems that originated on one CPU and were then ported to different CPUs whose native word size was different. To maintain source code compatibility, some of the OSes broke with that definition and kept the data types at their old sizes, and added new, non-standard ones.

    That said, depending on what you actually need, you might find some useful data types in stdint.h, or compiler-specific or platform-specific macros for various purposes.

提交回复
热议问题