From 3ce1642f4c3037030063b6ec3bb965739267cf65 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Thu, 5 May 2022 10:15:34 +0800 Subject: [PATCH] plugins: image formats - fix odr violation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When linking Qt statically, the image fomats are not separated into different DSOs. when linking them into the same target, gcc warns about an ODR violation between icohandler and bmphandler: ``` /usr/src/debug/qtbase/6.3.0-r0/build/include/QtGui/6.3.0/QtGui/private/../../../../../../git/src/gui/image/qbmphandler_p.h:69:8: warning: type ‘struct BMP_INFOHDR’ violates the C++ One Definition Rule [-Wodr] /usr/src/debug/qtbase/6.3.0-r0/git/src/plugins/imageformats/ico/qicohandler.cpp:98: note: a different type is defined in another translation unit /usr/src/debug/qtbase/6.3.0-r0/build/include/QtGui/6.3.0/QtGui/private/../../../../../../git/src/gui/image/qbmphandler_p.h:70:13: note: the first difference of corresponding definitions is field ‘biSize’ /usr/src/debug/qtbase/6.3.0-r0/git/src/plugins/imageformats/ico/qicohandler.cpp:87: note: a field of same name but different type is defined in another translation unit /usr/src/debug/qtbase/6.3.0-r0/build/include/QtGui/6.3.0/QtGui/private/../../../../../../git/src/gui/image/qbmphandler_p.h:69:8: note: type ‘qint32’ should match type ‘struct quint32_le’ ``` we therefore wrap the `BMP_INFOHDR` into an anonymous namespace Change-Id: I0e6ee66dd09ebda0c3e399738b5c172a57beb8f4 Pick-to: 5.15 6.2 6.3 Reviewed-by: Marc Mutz --- src/plugins/imageformats/ico/qicohandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index e1811e861d6..1307101f456 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -59,6 +59,8 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcIco, "qt.gui.imageio.ico") +namespace { + // These next two structs represent how the icon information is stored // in an ICO file. typedef struct @@ -98,6 +100,8 @@ typedef struct { // BMP information header } BMP_INFOHDR ,*LPBMP_INFOHDR; #define BMP_INFOHDR_SIZE 40 +} + class ICOReader { public: