MSVC build error

Nicolás Alvarez nicolas.alvarez at gmail.com
Wed Dec 17 23:47:20 UTC 2014


Hi people,

KDevelop has code like this in makebuilderpreferences.h:

class MakeBuilderSettings ;

template<typename T>
class ProjectConfigPage {
public:
    virtual ~ProjectConfigPage() {
        delete T::self();
    }
};
class MakeBuilderPreferences : public ProjectConfigPage<MakeBuilderSettings>
> {};

This doesn't compile on MSVC, it wants a full declaration (not just a
forward declaration) of MakeBuilderSettings , otherwise it says
MakeBuilderSettings is an undefined type and it doesn't find self().
Apparently the virtualness of the destructor is relevant(!).

It seems like this would be easy to fix, just include the generated
makebuilderconfig.h which defines the full MakeBuilderSettings class,
instead of forward-declaring it. Except we have a problem:
makebuilderconfig.h includes makebuilderpreferences.h, so they would
include each other. This causes a different build error when
makebuilderconfig.cpp is compiled.

This in turn can be solved by including makebuilderpreferences.h in
makebuilderconfig.cpp instead of in makebuilderconfig.h, since it's
only needed in the .cpp. But makebuilderconfig.* are generated from
the .kcfg files, so I'd have to modify the generator! However, this is
the only solution I found myself.

Is there anyone familiar with this code who could do some other code
change to avoid the problem? Otherwise I'll try to modify the kcfg
generator and send a review request...

-- 
Nicolás


More information about the KDevelop-devel mailing list