Performance of 32-bit integers in a 64-bit environment (C++)

后端 未结 6 1308
一个人的身影
一个人的身影 2021-02-20 01:00

We\'ve started compiling both 32- and 64-bit versions of some of our applications. One of the guys on my project is encouraging us to switch all of our 32-bit integers to their

6条回答
  •  南笙
    南笙 (楼主)
    2021-02-20 01:19

    Firstly, using 64-bit ints instead of 32-bit ints in 64-bit environment will not generally speed-up anything. Depending on the context and on the compiler abilities, this might actually slow things down. Normally, you should prefer using int/unsigned int types for storing integral values in your program, switching to other types only when really necessary. In the end, the definitive answer to the question can only be obtained by an actual experiment, since it depends on too many variables.

    Secondly, anyone who advises using size_t for that purpose (as a generic unsigned type) should be immediately denied access to code and sent to take some C/C++ classes before they are allowed to touch the code again.

提交回复
热议问题