PDA

View Full Version : How to know the operating system?



Dark_Tower
1st May 2006, 15:13
Hi there, I wanto to know wha'ts the best/easy way to know in wich operating system the application is running. I need to know it because I want to execute different instructions depending on the OS...

munna
1st May 2006, 15:24
use #ifdef WIN32

It tells you that the OS is some windows flavor. Likewise there are macros defined for *nix and mac. But I don't knw the words used for *nix and mac. I think it should be UNIX and MAC

GreyGeek
1st May 2006, 20:14
The "Assistant" has a topic called:


All Overviews and HOWTOs

and under it is another topic:


Window System Specific Notes

The second tells you all you need to know, with examples.

Glitch
2nd May 2006, 20:40
There are a couple thing Qt does for you to let you know at compile time what OS you are compiling for. Of course Qt is "Write once, Compile Everywhere". There are some generic defines based on your windowing system like

Q_WS_X11
Q_WS_WIN
Q_WS_MAC

This can narrow things down quite a bit sine you can say if I'm on windows do the win32 thing else do the POSIX thing.

There are some OS specific ones but they are too specific for most applications

Q_OS_IRIX
Q_OS_LINUX
Q_OS_FREEBSD
Q_OS_BSD4
Q_OS_WIN32

These can help you when you want a list of network interface on IRIX etc. Where code varies greatly between very specific OSs.

Of course see Assistant for a full list.

--Justin Noel
justin@ics.com

fullmetalcoder
4th May 2006, 20:41
you may also have a look at QSysInfo. In combination with these macros it allows you to determine what version of Window$ or Mac OS X are running, which can be useful if your app use a component that is not provided by Win9x but by WinXP...