canardman
canardman

Reputation: 3263

error: expected unqualified-id before string constant

After some research, i still don't understand the problem.

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 :

#include "Const.hpp"
func() {

    QString abc = STRSEP;

}

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;

EDIT: Error's detail :

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

Upvotes: 2

Views: 15840

Answers (2)

Simone
Simone

Reputation: 11797

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.

Upvotes: 7

Mark B
Mark B

Reputation: 96243

Try defining the two constants using two separate statements. It's the only thing that I can think of that might have an effect.

Upvotes: 2

Related Questions