0
我编译非常简单的代码,并作为输出我收到错误:用户自定义文字和空白和C++ 11点的问题
`../untitled6/main.cpp:17:1: error: unable to find string literal operator 'operator"" __FILE__'
connect(&d_t, SIGNAL(timeout()), this, SLOT(doPlay()));`
的代码如下:
#include <QObject>
#include <QTimer>
class Test : public QObject
{
Q_OBJECT
public:
explicit Test(QObject *parent = 0) : QObject(parent) {}
void Play()
{
connect(&d_t, SIGNAL(timeout()), this, SLOT(doPlay()));
}
public slots:
void doPlay() {}
private:
QTimer d_t;
};
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Test test;
test.Play();
return a.exec();
}
这是只有在我的项目中包含C++ 11支持时才会发生。没有这种支持,编辑是Okey。我已阅读了有关gcc ver的用户定义的文字和空白。 4.7包含C++ 11支持。但我的代码不包括任何代码FILE ....我发现这个问题与SIGNAL和SLOT结构有关。但我不知道这里有什么问题... P.S.对于编译,我使用sh4-linux-g ++(GCC)4.8。
我发现在发布版本配置中没有发现这个问题。现在看来,这是调试生成配置问题...
SIGNAL和SLOT(来自Qt)是宏在这里显然扩展为不正确的代码。您应该尝试分析结果代码(使用'gcc -E'并查看该行)。 – Tali
你用什么命令来编译代码?由于该文件包含Q_OBJECT宏,您是否使用“moc”(https://doc.qt.io/qt-4.8/moc.html)? –