When is uintptr_t preferred over intptr_t?

前端 未结 4 2078
甜味超标
甜味超标 2021-02-05 09:30

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:18

    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).

提交回复
热议问题