In this answer, int8_t*
is used for (byte) pointer arithmetic:
std::size_t offset = offsetof(Thing, b);
Thing* thing = reinterpret_cast<Thing*>(reinterpret_cast<int8_t*>(ptr) - offset);
I've always used char*
in the past but the comments are really confusing, and nobody responded, so I posted this separate question.
Is char*
valid, and the preferred way of doing these calculations?