错误:字符串常量之前的预期unqualified-id

can*_*man 2 c++

经过一番研究,我仍然不明白这个问题.

Const.hpp:

#ifndef CONST_HPP
#define CONST_HPP

#include <QString>

    const QString   CONFFILENAME("dsibubble.ini"),
                    STRSEP(" | ");

    const int       MAXIMGWIDTH = 960;

#endif // CONST_HPP  
Run Code Online (Sandbox Code Playgroud)

TabDataBase.cpp:

#include "Const.hpp"
func() {

    QString abc = STRSEP;

}
Run Code Online (Sandbox Code Playgroud)

使用STRSEP生成expected unqualified-id before string constant错误.此外,我CONFFILENAME在其他类使用,我没有错误.

QString path = QString("..//") + CONFFILENAME;
Run Code Online (Sandbox Code Playgroud)

编辑:错误的细节:

In file included ..\TabDataBase.cpp: #include "Const.hpp"  
expected unqualified-id before string constant: Const.hpp : STRSEP(" | ");
Run Code Online (Sandbox Code Playgroud)

Sim*_*one 7

我认为您已将STRSEP定义为字符串文字,如:

#define STRSEP "blahblah"
Run Code Online (Sandbox Code Playgroud)

因为我编译了你的代码片段并且很好,但是添加一个类似于前一个的定义我得到了同样的错误.