My normal advice:
reinterpret_cast<>
is to be used only as a last resort. You're telling the compiler to throw away all caution, 'remove all the safeties', and trust your word that it is really Ok, no matter what the compiler knows about the code. You should only use it when nothing else will work.
There will be places where they might have the same effect IF you got the code right. If you eventually make changes and introduce a mistake and the cast is not correct anymore, static_cast<>
will probably catch it, but reinterpret_cast<>
will certainly not.
In this very particular scenario, that last argument doesn't hold as much: The API is imposing the semantics on you; they are well understood semantics; and you are casting a (void *).
Still, I would use static_cast<>
, and leave reinterpret_cast<>
for places where truly extraordinary circumstances force me to bypass the type safety. This is a "normal" cast that is required because of the C-compatible nature of the API.
(see also my post here for more details on the differences between static_cast<> and reinterpret_cast<>)