KDE LogoKDElibs.com
Cross-platform KDE Development











Porting to MS Windows

Table of contents

Errors

MSVC is a different compiler so naturally one might encounter errors while compiling KDE apps. Here is a bunch of tips on how to understand and fix them.

Learn what the error means

The compiler presents error in a form of:

   PATH_TO_FILE(LINE) : error Cnnnn: error text

For example:

   D:\Oss\kdelibs4\kio\misc\kwalletd\kwalletd.cpp(426) :
    error C2653: 'KWin' : is not a class or namespace name

To learn what the error means go to the following url:

http://msdn.microsoft.com/library/default.asp ?url=/library/en-us/vccore/html/Cnnnn.asp

where nnnn is the number of the error MSVC reports.


Common errors

Using reserved identifiers

Using internal names for enum state naming, like

   enum {
       ERROR = 0,
       DATA
   } status;

Is wrong because ERROR is already used elsewhere in MSVC. So if you have a parsing problem around enums, just prefix the values with sth like STATUS_ or similar related to what information the enum stores.

Q_OBJECT problems with exports

   file(39): see previous definition of 'public:
                static QMetaObject const <YourClass>::staticMetaObject'
   file(39) : error C2491: '<YourClass>::staticMetaObject' : definition of
                dllimport static data member not allowed

YourClass probably uses some kind of visibility macro, this does not work with QOBJECT, which adds several static data to your class. Instead use the visibility macro on relevant methods you want to export, not on the entire class.

#warning directive

The directive #warning is a GCC extension, so if you get:

   file(line) : fatal error C1021: invalid preprocessor command 'warning'

go to the relevant place in the file and add relevant ifdef's like the following:

   #ifdef  __GNUC__
   #warning warning msg
   #endif