I am working with Qt in a cross-platform environment. And we are running into the following problem: On Windows, both int and long int are 32-bit integers; on 64-bit MacOS and Linux, int is 32-bit and long int is 64 bit (see https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models).
So, cross-platform libraries tend to provide their own fixed-bit typedefs. On Windows, Qt defines quint32 to be a unsigned int and does not use unsigned long integers. Another library defines its Uint32 however to be unsigned long. So, both are in fact 32-bit unsigned integers but have a different primitive data-type.
Now, it happens, that we try to use QDataStream serialization which is defined for quint32 with Uint32 data and to our surprise (or not), Visual C++ complains about the QDataStream operators not being defined for unsigned long which is true because Qt uses the almost equivalent unsigned int instead.
OK, the workaround is to provide
#ifdef Q_OS_WIN
inline QDataStream & operator >> (QDataStream & stream, Uint32 & value)
{ return stream >> reinterpret_cast<quint32 &>(value); }
inline QDataStream & operator << (QDataStream & stream, Uint32 value)
{ return stream << quint32(value); }
#endif // def Q_OS_WIN
My question is: Why do I need to reinterpret_cast? I would feel way more comfortable with a static_cast given that to my understanding the data-types are in fact the same. Here be dragons?
 
    