size_t, intptr_t, and uintptr_t for math in c -


i ran smallish issue when working size_t values in code.

first wanted use size_t because it's [guaranteed] same size on platforms, way going 32 64 bit shouldn't cause issues.

then negated size_t value , got big number, looking realized size_t unsigned. there intptr_t signed should used pointers , there's uintptr_t unsigned , used pointers.

my eventual goal implement simple set of fixed point math functions in c.

my question is can use uintptr_t int in calculations? cause issues?

you consider ptrdiff_t type difference of pointers produces. on common platforms should signed type corresponding size_t.


Comments