From 614589d844921e351e5422ba4a9b55aac22566c5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 22 Jan 2014 11:13:44 -0800 Subject: Work around a binary incompatibility in MSVC The fix in b8fe5e1bbc7f341d03d2704a6110d6e3240589bb (for bug QTBUG-27277) created two sets of begin() and end() functions for QVector. That was required because QTypedArrayData::iterator and QTypedArrayData::const_iterator have non-implicit copy constructors, which means the variants returning a strict iterator need to pass the storage pointer as an implicit first parameter. With the fix, the compiler would emit functions with two different names for each variant, which couldn't be merged. If we remove those copy constructors, the compiler might be able to generate the same code (no implicit first parameter) for both functions. Now, enter MSVC. Due to QPolygon, QVector and QVector are "extern templates". That is, the compiler is not allowed to inline anything, it must generate calls into QtCore (which we must fix for Qt 6, if we can). That means QtCore would only have one set of begin() / end() functions. If an application tried to use the other set by defining QT_STRICT_ITERATORS, you'd get a linker error for: ?begin@?$QVector@VQPoint@@@@QEAA?AViterator@?$QTypedArrayData@VQPoint@@@@V23@@Z (class QTypedArrayData::iterator QGenericArray::begin(class QTypedArrayData::iterator)) Change-Id: I5c10a7d0a4855f4ba84056d313c6a800ecdcfe37 Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart --- src/corelib/tools/qvector_msvc.cpp | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/corelib/tools/qvector_msvc.cpp (limited to 'src/corelib/tools/qvector_msvc.cpp') diff --git a/src/corelib/tools/qvector_msvc.cpp b/src/corelib/tools/qvector_msvc.cpp new file mode 100644 index 0000000000..8570fcf5fe --- /dev/null +++ b/src/corelib/tools/qvector_msvc.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Intel Corporation +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// ### Qt6: verify if we can remove this, somehow. +// First, try to see if the extern template from qvector.h is necessary. +// If it still is, check if removing the copy constructors in qarraydata.h +// make the calling convention of both sets of begin() and end() functions +// match, as it does for the IA-64 C++ ABI. + +#ifdef QVECTOR_H +# error "This file must be compiled with no precompiled headers" +#endif + +// invert the setting of QT_STRICT_ITERATORS, whichever it was +#ifdef QT_STRICT_ITERATORS +# undef QT_STRICT_ITERATORS +#else +# define QT_STRICT_ITERATORS +#endif + +// the Q_TEMPLATE_EXTERN at the bottom of qvector.h will do the trick +#include -- cgit v1.2.3