PDA

View Full Version : How to differentiate between operating systems inside the .cpp



Momergil
30th November 2011, 20:02
Hello!

Looking in Qwt examples I noticed that in the .pro file is possible to change the way the software is configured by putting some code inside a "label" defining for each operating system that code is valid. So for example, a code specific for Windows would be:


win32 {
.....
}

while for linux:


unix {

...


}

Now the problem is that I would like to have such possibility to be put inside the .cpp file. This is so because I'm developing a software in Linux but from time to time I have to pass it to Windows, and still of having to memorize each of the modifications I have to do when doing the change such possibility would help me making this process easier.

So is there a way to say to my code that it has to use a specific part of it given one or other operating system as can be done in the .pro file?


Thanks!


Momergil

Oleg
30th November 2011, 20:11
Use defines like Q_OS_WIN32 or Q_OS_UNIX, see Global Qt Declarations

Momergil
1st December 2011, 21:09
Use defines like Q_OS_WIN32 or Q_OS_UNIX, see Global Qt Declarations


Thanks!

God bless,

Momergil