[Qt-creator] portability fixes

Eike Ziller eike.ziller at nokia.com
Fri Jun 5 11:58:44 CEST 2009


On Jun 3, 2009, at 9:12 PM, ext Oswald Buddenhagen wrote:

> moin,
>
> i just checked in a bunch of platform conditional fixes and  
> unifications
> (*). as i prefer not to repeat this "fun" before every release, please
> try to obey these rules:
>
> - use Q_OS_UNIX instead of Q_OS_LINUX unless you *really* mean linux.

Additional note, because it's often forgotten: Mac is unix.
- use Q_OS_UNIX instead of Q_OS_LINUX only if you *really* mean unix.  
If you mean "unix but not Mac" use either "defined(Q_OS_UNIX) && ! 
defined(Q_OS_MAC)" or the cascading style below, checking Q_OS_MAC  
before checking Q_OS_UNIX.

>
>  for consistency, use Q_OS_MAC and Q_OS_WIN instead of Q_OS_DARWIN,
>  Q_OS_MACX and Q_OS_WIN32.
>
> - mostly academic in our environment: for ui-related conditionals (and
>  *only* those), use Q_WS_MAC, Q_WS_WIN and Q_WS_X11 instead of the
>  Q_OS_* defines.
>
> - use "cascades" of the type
>    #if defined(Q_OS_WIN)
>    #elif defined(Q_OS_MAC)
>    #else // UNIX
>    #endif
>  instead of "free-standing" consecutive #ifdefs. it's simpler to  
> verify
>  that all cases are covered that way. for uniformity, please try to
>  use the order given above.
>
> - if you add some platform-specific code in an #ifdef, please make  
> sure
>  that you put the pre-existing code into an #else branch if  
> applicable.
>  i found several cases were code would be just unreachable on certain
>  platforms. this makes it both harder to follow the logic and makes
>  some compiler configurations spit out warnings.
>
> - install targets should be conditional on unix:!macx
>
> have fun
>
> (*) i hope it still compiles on non-linux :-D

I hope it still works on Mac :P ;)

-- 
Eike Ziller
Software Engineer
Nokia, Qt Software
Phone  +49 (0)30 6392 3255
Fax    +49 (0)30 6392 3256
E-mail eike.ziller at nokia.com







More information about the Qt-creator-old mailing list