I need to figure out the operating system my program is running on during runtime.
I’m using Qt 4.6.2, MinGW and Eclipse with CDT. My program shall run a command-line QProcess on Windows or Linux. Now I need a kind of switch to run the different code depending on the operating system.
Actually the Operating System is defined by the Q_OS_… macros. Just saying. The Q_WS_… are windowing system. Not exactly the same. (I’m just reading what the author of the question wrote…. "operating system".)
These declarations are found in the qglobal.h file.
The window system definitions are like this:
One of the main problems with using #ifdef is to make sure that if you compile on a "new" platform (never compiled that software on that platform) then you want to use
#elif defined(...)and at least an#else+#error…