Reputation: 4674
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.
Upvotes: 11
Views: 6976
Reputation: 1
Some forward declarations seem to cause this warning too. Removing the 'template class MutexQList' line in this class example solves the issue in my case:
#include "bufferwriter.h"
#include "resampleworker.h"
#include "worker_help.h"
class Buffer;
class Project;
template <class T> class MutexQList;
class WorkerRegistry : public QObject
{
Q_OBJECT
private:
static WorkerRegistry *my_instance;
MutexQList<BufferWriter *>*bw_list; ///< Liste mit registrierten BufferWriter Instanzen
MutexQList<ResampleWorker *>*rw_list; ///< Liste mit registrierten ResampleWorker Instanzen
public:
static WorkerRegistry *instance();
static WorkerRegistry &ref();
static void destroy();
}
Upvotes: 0
Reputation: 2179
This error occurs also if the tr()
-macro is placed in too deeply nested subfolders.
E.g., in the following example, the command
lupdate -noobsolete . -ts ts/*
error message reads
pwd/a/b/c/c.cpp:5: Qualifying with unknown namespace/class ::C
.
QT += core gui
SOURCES += \
main.cpp \
a/a.cpp \
a/b/b.cpp \
a/b/c/c.cpp
HEADERS += \
a/a.h \
a/b/b.h \
a/b/c/c.h
TRANSLATIONS += \
ts/foo.ts
However, as others have already mentioned, the *.ts
-file seems to be updated correctly.
Upvotes: 0
Reputation: 4869
In my case there was a strangely (but legally I guess) formatted type declaration in a struct before the actual class declaration. This made lupdate
skip the class and resulted in the "unqualified" warning message. The code looked like this (wasn't mine to begin with ;-) ):
struct coords_t {
double x, y;
...
};
struct plotsCollection {
QVarLengthArray<struct coords_t> coords; // problem right here
...
};
class LogsDialog : public QDialog
{
Q_OBJECT
...
}
Removing the struct
from QVarLengthArray<struct coords_t>
solved the warning. So did moving the struct declarations inside the class. I did both :)
Upvotes: 2
Reputation: 481
I have seen this error message too using Qt 5.4.1 on an Ubuntu 12.04 system.
But the reason for the error was different. "lupdate" seems to have problems with C++-11 strong enums, at least when using related forward declarations encapsulated in a namespace.
I'm using something like this in the related header file:
namespace outer {
namespace other {
enum class MyEnum : int;
} // namespace outer::other
namespace inner {
class MyClass {
//...
};
} // namespace outer::inner
} // namespace outer
The problem with "lupdate" can be worked around by using a marco for the term "enum class":
#ifndef ENUM_CLASS
#define ENUM_CLASS enum class
#endif
namespace outer {
namespace other {
ENUM_CLASS MyEnum : int;
} // namespace outer::other
namespace inner {
class MyClass {
//...
};
} // namespace outer::inner
} // namespace outer
Upvotes: 2
Reputation: 41
In my case lupdate wasn't able to parse enum MyEnum:int {}; line and failed to reach class declaration. Qt 5.7.1, lupdate still does not understand type specifiers for enums.
Upvotes: 4
Reputation: 9398
I just got this same message in a different scenario. In my case, the issue was that foo.cpp
contained #include <foo.h>
instead #include "foo.h"
. Since both files were a directory that wasn't in the global include path, lupdate
didn't bother looking in that directory due to the lack of quotation marks in the include. Switching to the proper include delimiters made lupdate
happy.
Upvotes: 1
Reputation: 4674
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?
Upvotes: 11