[Interest] Qt5 +CLR -> linker error LNK2005 workaround

Franz Hirschbeck franz.hirschbeck at frahi.de
Fri Jun 21 10:32:39 CEST 2013


Hello everyone,

just wanted to let you know, that we have a small workaround here in the 
meantime.

The problem is that the CLR linker does not detect that these 
instantiations are identical. To avoid this problem we replaced the 
"inline" instantiation with an explicit instantiation in exactly one cpp 
file (or object file).

Best regards,
Franz Hirschbeck

-- 
Franz Hirschbeck, Dipl.-Inf.
Software Department

CT Imaging GmbH                                 Tel.: +49-9131-97310-21
Henkestr. 91                                    Fax.: +49-9131-97310-10
91052 Erlangen                                  http://www.ct-imaging.de

Amtsgericht Fürth/Bay. HRB 11567
Ust. IdNr.: DE261272554
Geschäftsführer: Prof. Dr. Willi Kalender; Dipl. Kfm. Georg Ruile
-------------- next part --------------
diff -Naur qt-everywhere-opensource-src-5.0.1/qtbase/src/corelib/tools/qstringlist.cpp qt-everywhere-opensource-src-5.0.1_patched/qtbase/src/corelib/tools/qstringlist.cpp
--- qt-everywhere-opensource-src-5.0.1/qtbase/src/corelib/tools/qstringlist.cpp	Tue Jan 29 19:03:01 2013
+++ qt-everywhere-opensource-src-5.0.1_patched/qtbase/src/corelib/tools/qstringlist.cpp	Tue Feb  5 08:52:05 2013
@@ -177,6 +177,8 @@
     Constructs an empty string list.
 */
 
+QStringList::QStringList() { }
+
 /*!
     \fn QStringList::QStringList(const QString &str)
 
@@ -188,6 +190,8 @@
     \sa append()
 */
 
+QStringList::QStringList(const QString &i) { append(i); }
+
 /*!
     \fn QStringList::QStringList(const QStringList &other)
 
@@ -202,6 +206,8 @@
     \sa operator=()
 */
 
+QStringList::QStringList(const QStringList &l) : QList<QString>(l) { }
+
 /*!
     \fn QStringList::QStringList(const QList<QString> &other)
 
@@ -215,6 +221,8 @@
     \sa operator=()
 */
 
+QStringList::QStringList(const QList<QString> &l) : QList<QString>(l) { }
+
 /*!
     \fn void QStringList::sort(Qt::CaseSensitivity cs)
 
@@ -473,6 +481,12 @@
 
     \sa append()
 */
+QStringList QStringList::operator+(const QStringList &other) const
+{ 
+	QStringList n = *this; 
+	n += other; 
+	return n; 
+}
 
 /*!
     \fn QStringList &QStringList::operator<<(const QString &str)
@@ -482,6 +496,11 @@
 
     \sa append()
 */
+QStringList &QStringList::operator<<(const QString &str)
+{ 
+	append(str); 
+	return *this; 
+}
 
 /*!
     \fn QStringList &QStringList::operator<<(const QStringList &other)
@@ -491,6 +510,12 @@
     Appends the \a other string list to the string list and returns a reference to
     the latter string list.
 */
+
+QStringList &QStringList::operator<<(const QStringList &l)
+{ 
+	*this += l; 
+	return *this; 
+}
 
 #ifndef QT_NO_DATASTREAM
 /*!
diff -Naur qt-everywhere-opensource-src-5.0.1/qtbase/src/corelib/tools/qstringlist.h qt-everywhere-opensource-src-5.0.1_patched/qtbase/src/corelib/tools/qstringlist.h
--- qt-everywhere-opensource-src-5.0.1/qtbase/src/corelib/tools/qstringlist.h	Tue Jan 29 19:03:01 2013
+++ qt-everywhere-opensource-src-5.0.1_patched/qtbase/src/corelib/tools/qstringlist.h	Tue Feb  5 08:53:54 2013
@@ -63,10 +63,10 @@
 class QStringList : public QList<QString>
 {
 public:
-    inline QStringList() { }
-    inline explicit QStringList(const QString &i) { append(i); }
-    inline QStringList(const QStringList &l) : QList<QString>(l) { }
-    inline QStringList(const QList<QString> &l) : QList<QString>(l) { }
+    Q_CORE_EXPORT QStringList();
+    Q_CORE_EXPORT explicit QStringList(const QString &i);
+    Q_CORE_EXPORT QStringList(const QStringList &l);
+    Q_CORE_EXPORT QStringList(const QList<QString> &l);
 #ifdef Q_COMPILER_INITIALIZER_LISTS
     inline QStringList(std::initializer_list<QString> args) : QList<QString>(args) { }
 #endif
@@ -82,12 +82,9 @@
 
     inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
 
-    inline QStringList operator+(const QStringList &other) const
-    { QStringList n = *this; n += other; return n; }
-    inline QStringList &operator<<(const QString &str)
-    { append(str); return *this; }
-    inline QStringList &operator<<(const QStringList &l)
-    { *this += l; return *this; }
+    Q_CORE_EXPORT QStringList operator+(const QStringList &other) const;
+    Q_CORE_EXPORT QStringList &operator<<(const QString &str);
+    Q_CORE_EXPORT QStringList &operator<<(const QStringList &l);
 
 #ifndef QT_NO_REGEXP
     inline QStringList filter(const QRegExp &rx) const;


More information about the Interest mailing list