I'm running "QUdpSocket::ShareAddress" on my QT application but ShareAddress is ignored by windows. So I'm trying to solve this problem by identifying OS at run time. I heard a couple of information about window versi开发者_开发技巧on indentifier but I couldn't see any solution to solve my problem. If there is any of advice, it would be very appreciated. Thanks.
#include <QtGlobal>
...
#ifdef Q_OS_MAC
// mac
#endif
#ifdef Q_OS_LINUX
// linux
#endif
#ifdef Q_OS_WIN32
// win
#endif
See QtGlobal documentation for further information.
It isn't always the most elegant solution, but it's definitely effective to use a preprocessor definition to check platform at compile time.
Example:
#ifdef _WIN32
#endif
精彩评论