#if/#endif directives change behaviour of vtable [solved]
-
Can someone explain that to me:
This code here produces an “undefined reference to vtable” error:
@
#ifdef ANDROID
#ifndef ANDROIDLOGIN_HPP
#define ANDROIDLOGIN_HPP
#include <QObject>
class LoginSystem : public QObject
{
Q_OBJECT
public:
explicit LoginSystem(QObject *parent = 0);
signals:
void accessTokenRceived(QString);
public slots:
void login();
};
#endif // ANDROIDLOGIN_HPP
#endif
@While this one works fine:
@
#ifndef ANDROIDLOGIN_HPP
#define ANDROIDLOGIN_HPP
#include <QObject>
class LoginSystem : public QObject
{
Q_OBJECT
public:
explicit LoginSystem(QObject *parent = 0);
signals:
void accessTokenRceived(QString);
public slots:
void login();
};
#endif // ANDROIDLOGIN_HPP@
The strange part is, when the first one is compiled for PC everything works fine. When its compiled for android ld prints out:
“../tiz/src/facebook/login/androidLogin.cpp:7: error: undefined reference to 'vtable for LoginSystem'”What am I doing wrong? Isn't it the sense of the #if/#endif directives to only cut out code? So in case of compiling for android I expected them to behave like they wouldn't be there.
Also here is the cpp:
@
#ifdef ANDROID
#include "androidLogin.hpp"
LoginSystem::LoginSystem(QObject *parent) :
QObject(parent)
{
}
void LoginSystem::login()
{
}
#endif@
-
Hi,
That might be a problem related to moc.
However in your case rather than "hiding" a class like that, you should only compile it when doing an android build e.g. use the android scope in your pro file, and not build it for the other platforms.
Hope it helps
-
all right thanks