Operating System Dependencies

Das KDevelop-Programmierhandbuch: Leitfaden zur C++-Anwendungsentwicklung für das K Desktop Environment (KDE) mit Hilfe der KDevelop-IDE in der Version 1.2
Zurück | Kapitel 15. Programming Guidelines | Vor

# 15.2. Operating System Dependencies

As KDevelop projects use the GNU tools to create projects, it is ensured that your application will run on almost every Unix system. However, you may encounter problems when actually compiling your application under another Unix, because header files are located somewhere different or you need another implementation especially when it comes to using OS-specific low-level functions which can differ from system to system.

When programming with C++ and Qt/KDE you should also notice that the Qt collection classes have a rich set of functionality that is already compiler/OS independend and makes things much easier, starting with strings (QString) to file reading/writing (QFile); so using Qt will make using OS defines almost obsolete in most cases.

Anyway, when using Qt and you still have to use &#;defines for your application, you should include `qglobal.h` and make use of the already predefined defines for various Operating Systems and compilers which preselects the below defines already.

Instead of letting the packagers of OS-Vendors applying any patches to your application (like most do where necessary e.g. for building rpm´s or packages/ports), you should use defines for those sections that are operating-system specific (but you don´t have to use -D for compiling, the Operating System defines are handled automatically). The following lists the available systems and their defines (additional defines in brackets):

AIX:

  &#;ifdef &_;AIX

BSDI Unix:

  &#;if defined(bsdi) &|;&|; defined(&_;&_;bsdi&_;&_;)

Dec Ultrix:

  &#;if defined (ultrix) &|;&|; defined(&_;&_;ultrix) &|;&|; defined(&_;&_;ultrix&_;&_;)

DG Unix:

  &#;if defined(DGUX)

FreeBSD:

  &#;ifdef &_;&_;FreeBSD&_;&_;

GNU Hurd:

  &#;if defined(&_;&_;GNU&_;&_;)

HP-UX:

  &#;if defined (hpux) &|;&|; defined (&_;&_;hpux) &|;&|; defined (&_;&_;hpux&_;&_;)

Linux:

  &#;if defined(linux) &|;&|; defined(&_;&_;linux) &|;&|; defined(&_;&_;linux&_;&_;)

NetBSD:

  &#;ifdef &_;&_;NetBSD&_;&_;

OpenBSD:

  &#;ifdef &_;&_;OpenBSD&_;&_;

OSF Unix:

  &#;if defined(&_;&_;osf&_;&_;)

QNX:

  &#;if defined(&_;&_;QNX&_;&_;)

SCO UnixWare:

  &#;if defined(&_;UNIXWARE)

SCO UnixWare 7:

  &#;if defined(sco) &|;&|; defined(&_;UNIXWARE7)

SCO:

  &#;if defined(&_;SCO&_;DS) &|;&|; defined(M&_;UNIX) &|;&|; defined(M&_;XENIX)

SGI Irix:

  &#;if defined(sgi) &|;&|; defined(&_;&_;sgi)

SunOS:

  &#;if defined (sun) &|;&|; defined (&_;&_;sun) &|;&|; defined (&_;&_;sun&_;&_;)

Sun Solaris:

  &#;if defined (&_;OS&_;SUN&_;) &|;&|; defined (&_;&_;SVR4)

Zurück | Anfang | Vor
Programming Guidelines | Hoch | Licensing