C++ offsetof char* arithmetic
问题 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? 回答1: You must use char* : the behaviour on using a reinterpret_cast with int8_t* on a pointer to something that