错误:字符串常量前的预期未限定标识 [英] error: expected unqualified-id before string constant
本文介绍了错误:字符串常量前的预期未限定标识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
经过一番研究,我仍然不明白这个问题。
After some research, i still don't understand the problem.
Const.hpp:
Const.hpp :
#ifndef CONST_HPP
#define CONST_HPP
#include <QString>
const QString CONFFILENAME("dsibubble.ini"),
STRSEP(" | ");
const int MAXIMGWIDTH = 960;
#endif // CONST_HPP
TabDataBase.cpp:
TabDataBase.cpp :
#include "Const.hpp"
func() {
QString abc = STRSEP;
}
使用 STRSEP
在字符串常量
之前生成预期的未限定ID。
此外,我在其他类中使用 CONFFILENAME
,我没有错误。
The use of STRSEP
generate an expected unqualified-id before string constant
error.
Moreover i use CONFFILENAME
in an other class and i have no error.
QString path = QString("..//") + CONFFILENAME;
编辑:错误的详细信息:
Error's detail :
In file included ..\TabDataBase.cpp: #include "Const.hpp"
expected unqualified-id before string constant: Const.hpp : STRSEP(" | ");
推荐答案
我认为你已经将STRSEP定义为字符串文字例如:
I think you have defined STRSEP as a string literal somewhere like:
#define STRSEP "blahblah"
因为我编译你的代码片段,它很好,但添加一个定义像上一个,我得到相同的错误。
Because I compiled your snippet and it's fine, but adding a define like the previous one I get the same error.
这篇关于错误:字符串常量前的预期未限定标识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文