How to handel platform specific code in qt
-
Hello,
I am developing a multiplatform application in qt. However, I would like to have some platform specific code, like grab a few messages from the windows api.I obliviously don't want this code when compiling for say Linux or Mac. What is the most common way to surpress or remove code on certain platforms?
The only time I have done this before is in unity 3d and they did it by automatically defining preprocessor defines on compile, so all you have to do is this:
#ifdef Windows
//windows only code here
#else
//code for other platforms here
#endif
Or
#ifdef Linux
// Linux only code here
#endif
I could use this method, but without the automatic preprocessor defines, everyone who wanted to compile it would have to manually define the platform. I was wondering of there was a more common or popular way.
-
Hi, seems you need to re-read the documentation of Qt:
Q_OS_WIN
Q_OS_UNIX
Q_OS_....Q_CC_MSVC
Q_CC_GNU
Q_CC_...Q_PROCESSOR_X86
Q_PROCESSOR_ARM
Q_PROCESSOR_.......
-
What is the link to that page in the documentation? I would really like to see it. I problaby couldn't find it because it was problaby called differently then what I googled for. I looked for "platform specific defines"
-