Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lupdate error: Qualifying with unknown namespace/class

I ran into a very peculiar error using lupdate v4.7.2. I got the error message

module/foo.cpp:6: Qualifying with unknown namespace/class ::foo

for a couple of classes in a project with about 50 classes. I boiled the problem down to a simple example:

src/project.pro:

QT       += core
TARGET = test
TEMPLATE = app

SOURCES += main.cpp \
           screen.cpp

HEADERS += screen.h

TRANSLATIONS += de.ts

src/module/foo.h:

namespace sp {
class foo {
    initWidgets();
};
} // namespace sp

src/module/foo.cpp:

#include <QString>
#include "module/foo.h"

namespace sp {
    foo::initWidgets() {
    QString bar = tr("bar");
}
} // namespace sp

main.cpp has an empty main function in it.

The code compiles (barring any copypasta mistakes I might have produced here), so the syntax is basically correct.

like image 375
arne Avatar asked Jun 28 '11 10:06

arne


1 Answers

The answer was that lupdate was unable to locate the header file foo.h while parsing foo.cpp. Extending the .pro file with the following line removed the issue:

INCLUDEPATH += .

However, what still bothers me a bit is that the compiler should have been unable to compile the code, but somehow, qmake added a -I. to the compiler options. That's why I didn't think of an include file issue earlier and spent a couple of hours puzzling this out. Does anyone know whether this is default behavior? Also: Why does lupdate not emit an appropriate error message?

like image 126
arne Avatar answered Oct 20 '22 07:10

arne