开发者

How to get OS information whether it be LINUX or WINDOWS?

开发者 https://www.devze.com 2022-12-11 01:50 出处:网络
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'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
0

精彩评论

暂无评论...
验证码 换一张
取 消