[Interest] QStringLiteral and UTF-16 string literal "u"

Cathal Tummon (ctummon) ctummon at cisco.com
Thu Jan 5 16:31:28 CET 2023


Sorry to drag this out, but even if my compiler is broken.
By the looks of it I do not need to manually add the "u" , it seems to be added by the QStringLiteral() macro itself?

-----Original Message-----
From: Thiago Macieira <thiago.macieira at intel.com> 
Sent: 05 January 2023 16:20
To: interest at qt-project.org
Cc: Cathal Tummon (ctummon) <ctummon at cisco.com>
Subject: Re: [Interest] QStringLiteral and UTF-16 string literal "u"

On Thursday, 5 January 2023 11:54:58 -03 Cathal Tummon (ctummon) via Interest
wrote:
> Sorry to clarify, I'm not questing why it is needed, my question is, 
> is the following redundant: QStringLiteral(u"myText")
> 
> As in the source code for QStringLiteral there is another macro:
> #define QT_UNICODE_LITERAL(str) u"" str
> 
> Which always seems to be used, is that correct?

Correct. The u is not required for any compliant compiler. The problem is only if your compiler is broken (i.e., MSVC).

See the discussion on commit d80b0eb12c477592b590b768e21dc26c137beadc[1] and on the MSFT bug report.

[1] https://code.qt.io/cgit/qt/qtbase.git/commit/?
id=d80b0eb12c477592b590b768e21dc26c137beadc

--
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering





More information about the Interest mailing list