Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-28885

QStringLiteral does not work with MSVC2010

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.1.0
    • 5.0.0
    • None
    • Vista SP2,MSVC2010
    • f3f60743551936e3d06f7f5c8bb2c76eab6d536c

    Description

      QStringLiteral has several problems on msvc2010

      I.

          // ok
          QString s = QLatin1String(
              "hello"
              "world");
      
          // fail
          QString t = QStringLiteral(
              "hello"
              "world");
      

      .\main.cpp(27) : error C2308: concatenating mismatched strings
      Concatenating wide "hello" with narrow "world"
      .\main.cpp(27) : error C2308: concatenating mismatched strings
      Concatenating wide "hello" with narrow "world"
      .\main.cpp(27) : error C2308: concatenating mismatched strings
      Concatenating wide "hello" with narrow "world"
      .\main.cpp(27) : error C2308: concatenating mismatched strings
      Concatenating wide "hello" with narrow "world"
      mainwindow.cpp

      There is known workaround, use

       QStringLiteral("\
      hello\
      cruel\
      world"); 

      instead;

      II.

       
      QString names[] = { QStringLiteral("hello"), QStringLiteral("world") }; 

      in global scope it fails with:

      .\main.cpp(12) : fatal error C1506: unrecoverable block scoping error

      in local scope it fails with an internal compiler error.

      III.

      template <typename T> struct MyTrait { static QString name; };
      template <> QString MyTrait<int>::name = QStringLiteral("int");
      

      .\main.cpp(10) : error C2332: 'enum' : missing tag name
      .\main.cpp(10) : error C2065: 'Size' : undeclared identifier
      .\main.cpp(10) : error C2552: 'qstring_literal' : non-aggregates cannot be initi
      alized with initializer list
      'QStaticStringData' : Types with user defined constructors are not aggre
      gate
      .\main.cpp(10) : error C2078: too many initializers
      .\main.cpp(10) : error C2065: 'Size' : undeclared identifier

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            mattc Matteo
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes