I’m sure I’m not alone in sometimes passing integer (or even character) data in the
data2 members of the SDL_UserEvent structure. Since these members are declared as
void* type I’ve no doubt that a pedant would say that using them for anything other than pointers is a sin, but for passing a simple
int this seems overkill and not without its own risks.
Accepting that it’s not the ‘proper’ way to do it, what’s the safest way of casting an int to a void* and back that is (a) guaranteed to return the original value on both 32-bit and 64-bit builds and (b) won’t provoke any compiler warnings? I’m currently using
(void*)(intptr_t) but with little confidence that it’s a safe method.