When is uintptr_t preferred over intptr_t?

前端 未结 4 614
粉色の甜心
粉色の甜心 2021-02-05 09:27

Given the requirement that I need to store the value of a \"generic\" pointer in a struct and have no interest in the pointed-at memory itself, I find it more semantically corre

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-05 10:20

    If you want to manipulate the value arithmetically (e.g., to encrypt it), you have much more flexibility with an unsigned type (where arithmetic wraps around) than with a signed type (where arithmetic overflow gives undefined behavior).

提交回复
热议问题