diff options
author | Tim Blechmann <[email protected]> | 2022-05-05 10:09:00 +0800 |
---|---|---|
committer | Qt Cherry-pick Bot <[email protected]> | 2024-02-06 20:25:16 +0000 |
commit | a55f3f8ef24424b3529f6e720a41bfe2b12d92c6 (patch) | |
tree | 3e7312bd58614e67f6f3804f6d0a0e8e5d6d2052 | |
parent | 2f4b8ebc49c16312f1e837edd8f5a136e19c7fe6 (diff) |
core/gui: fix odr violation
When linking Qt statically, QtCore and QtGui are not separated into
different DSOs.
when both statically linked versions of QtCore and QtGui are linked into
the same binary with LTO, gcc emits:
```
/usr/src/debug/qtbase/6.3.0-r0/git/src/gui/painting/qicc.cpp:105:
warning: type ‘Tag’ violates the C++ One Definition Rule [-Wodr]
/usr/src/debug/qtbase/6.3.0-r0/git/src/corelib/kernel/qtranslator.cpp:78:
note: an enum with different value name is defined in another
translation unit
/usr/src/debug/qtbase/6.3.0-r0/git/src/gui/painting/qicc.cpp:106: note:
name ‘acsp’ differs from name ‘Tag_End’ defined in another translation
unit
/usr/src/debug/qtbase/6.3.0-r0/git/src/corelib/kernel/qtranslator.cpp:78:
note: mismatching definition
```
we therefore define the `struct Tag` in an anonymous namespace or the
QIcc namespace
Change-Id: Ib4edeede35c51322ab1959d70fb87359b196e59b
Reviewed-by: Thiago Macieira <[email protected]>
(cherry picked from commit 6b13e0ca593592b34ea34837335db0d5cefdf630)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
(cherry picked from commit 1e5892f74a7950ba2d05bc507f2219a45fde3897)
(cherry picked from commit f4f809d51d9d4b120572f18e3ba7aa383159aad1)
-rw-r--r-- | src/corelib/kernel/qtranslator.cpp | 3 | ||||
-rw-r--r-- | src/gui/painting/qicc.cpp | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index 84d6925c0f1..39276a3f685 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -39,8 +39,11 @@ QT_BEGIN_NAMESPACE +namespace { enum Tag { Tag_End = 1, Tag_SourceText16, Tag_Translation, Tag_Context16, Tag_Obsolete1, Tag_SourceText, Tag_Context, Tag_Comment, Tag_Obsolete2 }; +} + /* $ mcookie 3cb86418caef9c95cd211cbf60a1bddd diff --git a/src/gui/painting/qicc.cpp b/src/gui/painting/qicc.cpp index 1f863635087..ccc01da68ad 100644 --- a/src/gui/painting/qicc.cpp +++ b/src/gui/painting/qicc.cpp @@ -20,6 +20,8 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcIcc, "qt.gui.icc", QtWarningMsg) +namespace QIcc { + struct ICCProfileHeader { quint32_be profileSize; @@ -104,7 +106,9 @@ enum class Tag : quint32 { aabg = IccTag('a', 'a', 'b', 'g'), }; -inline size_t qHash(const Tag &key, size_t seed = 0) +} // namespace QIcc + +inline size_t qHash(const QIcc::Tag &key, size_t seed = 0) { return qHash(quint32(key), seed); } |