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 |
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):
&#;ifdef &_;AIX
&#;if defined(bsdi) &|;&|; defined(&_;&_;bsdi&_;&_;)
&#;if defined (ultrix) &|;&|; defined(&_;&_;ultrix) &|;&|; defined(&_;&_;ultrix&_;&_;)
&#;if defined(DGUX)
&#;ifdef &_;&_;FreeBSD&_;&_;
&#;if defined(&_;&_;GNU&_;&_;)
&#;if defined (hpux) &|;&|; defined (&_;&_;hpux) &|;&|; defined (&_;&_;hpux&_;&_;)
&#;if defined(linux) &|;&|; defined(&_;&_;linux) &|;&|; defined(&_;&_;linux&_;&_;)
&#;ifdef &_;&_;NetBSD&_;&_;
&#;ifdef &_;&_;OpenBSD&_;&_;
&#;if defined(&_;&_;osf&_;&_;)
&#;if defined(&_;&_;QNX&_;&_;)
&#;if defined(&_;UNIXWARE)
&#;if defined(sco) &|;&|; defined(&_;UNIXWARE7)
&#;if defined(&_;SCO&_;DS) &|;&|; defined(M&_;UNIX) &|;&|; defined(M&_;XENIX)
&#;if defined(sgi) &|;&|; defined(&_;&_;sgi)
&#;if defined (sun) &|;&|; defined (&_;&_;sun) &|;&|; defined (&_;&_;sun&_;&_;)
&#;if defined (&_;OS&_;SUN&_;) &|;&|; defined (&_;&_;SVR4)