diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-04-30 09:39:21 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-06-28 06:47:29 +0200 |
commit | f66c1db16c050c9d685a44a38ad7c5cf9f6fcc96 (patch) | |
tree | 53e38e8714d493e321e0437f4d4f59bd6f4aff10 /qmake/generators/makefiledeps.cpp | |
parent | 8f0e3ad5188d17c88f624eeea9a67ab17e55cc6f (diff) | |
download | qtbase-f66c1db16c050c9d685a44a38ad7c5cf9f6fcc96.tar.gz |
Introduce Q_NAMESPACE_EXPORT
A recurring problem with the Q_NAMESPACE macro is that it declares
an object (staticMetaObject) in the surrounding namespace. That
object lacks any export/import qualification to make it usable
with shared libraries.
Introduce therefore another macro to work around this issue, allowing
the user to prefix the object with an exporting macro, f.i. like this:
Q_NAMESPACE_EXPORT(Q_CORE_EXPORT)
The old macro can simply then be rewritten in terms of this new one,
supplying an empty export macro.
Note that NOT passing an argument to a macro expecting one is well
defined behavior in C99 -- the macro will expand an empty token.
Of course, MSVC doesn't like this and emits warnings. As a
workaround, use a variadic macro.
[ChangeLog][QtCore] Added the new Q_NAMESPACE_EXPORT macro. It
can be used just like Q_NAMESPACE to add meta-object information
to a namespace; however it also supports exporting of such
information from shared libraries.
[ChangeLog][Potentially Source-Incompatible Changes] Prefixing
Q_NAMESPACE with an export macro may no longer work. Use the new
Q_NAMESPACE_EXPORT macro for that use case.
Fixes: QTBUG-68014
Change-Id: Ib044a555ace1f77ae8e0244d824ec473550f3d8e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Diffstat (limited to 'qmake/generators/makefiledeps.cpp')
-rw-r--r-- | qmake/generators/makefiledeps.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/qmake/generators/makefiledeps.cpp b/qmake/generators/makefiledeps.cpp index 1995cf63ba..69a3217723 100644 --- a/qmake/generators/makefiledeps.cpp +++ b/qmake/generators/makefiledeps.cpp @@ -946,10 +946,12 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file) debug_msg(2, "findMocs: %s", file->file.local().toLatin1().constData()); int line_count = 1; - bool ignore[3] = { false, false, false }; // [0] for Q_OBJECT, [1] for Q_GADGET, [2] for Q_NAMESPACE + // [0] for Q_OBJECT, [1] for Q_GADGET, [2] for Q_NAMESPACE, [3] for Q_NAMESPACE_EXPORT + bool ignore[4] = { false, false, false, false }; /* qmake ignore Q_GADGET */ /* qmake ignore Q_OBJECT */ /* qmake ignore Q_NAMESPACE */ + /* qmake ignore Q_NAMESPACE_EXPORT */ for(int x = 0; x < buffer_len; x++) { #define SKIP_BSNL(pos) skipEscapedLineEnds(buffer, buffer_len, (pos), &line_count) x = SKIP_BSNL(x); @@ -988,6 +990,12 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file) file->file.real().toLatin1().constData(), line_count); x += 23; ignore[2] = true; + } else if (buffer_len >= (x + 30) && + !strncmp(buffer + x + 1, "make ignore Q_NAMESPACE_EXPORT", 30)) { + debug_msg(2, "Mocgen: %s:%d Found \"qmake ignore Q_NAMESPACE_EXPORT\"", + file->file.real().toLatin1().constData(), line_count); + x += 30; + ignore[3] = true; } } else if (buffer[x] == '*') { extralines = 0; @@ -1015,8 +1023,8 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file) int morelines = 0; int y = skipEscapedLineEnds(buffer, buffer_len, x + 1, &morelines); if (buffer[y] == 'Q') { - static const char interesting[][12] = { "Q_OBJECT", "Q_GADGET", "Q_NAMESPACE"}; - for (int interest = 0; interest < 3; ++interest) { + static const char interesting[][19] = { "Q_OBJECT", "Q_GADGET", "Q_NAMESPACE", "Q_NAMESPACE_EXPORT" }; + for (int interest = 0; interest < 4; ++interest) { if (ignore[interest]) continue; |