summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qbytearray.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qbytearray.h')
-rw-r--r--src/corelib/tools/qbytearray.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 45be63aa9b..0f5ebcfb18 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -169,13 +169,14 @@ struct QByteArrayDataPtr
#if defined(Q_COMPILER_LAMBDA)
# define QByteArrayLiteral(str) \
- ([]() -> QByteArrayDataPtr { \
+ ([]() -> QByteArray { \
enum { Size = sizeof(str) - 1 }; \
static const QStaticByteArrayData<Size> qbytearray_literal = { \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER(Size), \
str }; \
QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; \
- return holder; \
+ const QByteArray ba(holder); \
+ return ba; \
}()) \
/**/
@@ -185,22 +186,22 @@ struct QByteArrayDataPtr
// To do that, we need the __extension__ {( )} trick which only GCC supports
# define QByteArrayLiteral(str) \
- __extension__ ({ \
+ QByteArray(__extension__ ({ \
enum { Size = sizeof(str) - 1 }; \
static const QStaticByteArrayData<Size> qbytearray_literal = { \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER(Size), \
str }; \
QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; \
holder; \
- }) \
+ })) \
/**/
#endif
#ifndef QByteArrayLiteral
-// no lambdas, not GCC, use const char * instead
+// no lambdas, not GCC, just return a temporary QByteArray
-# define QByteArrayLiteral(str) (str)
+# define QByteArrayLiteral(str) QByteArray(str, sizeof(str) - 1)
#endif
class Q_CORE_EXPORT QByteArray