From: Lars Knoll Date: Mon, 11 Jun 2012 14:08:55 +0000 (+0200) Subject: Don't use the gcc extension for QStringLiteral & Q_ARRAY_LITERAL X-Git-Tag: 071012110112~448 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69478da0f0d1eac9389fbd9d2f0bca3d0ce306a6;p=profile%2Fivi%2Fqtbase.git Don't use the gcc extension for QStringLiteral & Q_ARRAY_LITERAL The extension doesn't work outside of function scopes, so a function declaration such as void foo(const QString &str = QStringLiteral("bar")); would fail on certain gcc versions. Change-Id: I2971301f2859edd3fc81b95dfa5a7c15f29e395c Reviewed-by: Thiago Macieira Reviewed-by: Olivier Goffart --- diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index e9f70bc..f3de8de 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -315,14 +315,6 @@ struct QArrayDataPointerRef return StaticWrapper::get(); \ }()) \ /**/ -#elif defined(Q_CC_GNU) -// Hide array within GCC's __extension__ {( )} block -#define Q_ARRAY_LITERAL(Type, ...) \ - __extension__ ({ \ - Q_ARRAY_LITERAL_IMPL(Type, __VA_ARGS__) \ - ref; \ - }) \ - /**/ #endif #endif // defined(Q_COMPILER_VARIADIC_MACROS) diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 375dfbb..f136d74 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -167,22 +167,6 @@ Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2, }()) \ /**/ -# elif defined(Q_CC_GNU) -// We need to create a QStringData in the .rodata section of memory -// and the only way to do that is to create a "static const" variable. -// To do that, we need the __extension__ {( )} trick which only GCC supports - -# define QStringLiteral(str) \ - QString(__extension__ ({ \ - enum { Size = sizeof(QT_UNICODE_LITERAL(str))/2 - 1 }; \ - static const QStaticStringData qstring_literal = { \ - Q_STATIC_STRING_DATA_HEADER_INITIALIZER(Size), \ - QT_UNICODE_LITERAL(str) }; \ - QStringDataPtr holder = { qstring_literal.data_ptr() }; \ - holder; \ - })) \ - /**/ - # endif #endif // QT_NO_UNICODE_LITERAL