Uploaded image for project: 'Qt Visual Studio Tools'
  1. Qt Visual Studio Tools
  2. QTVSADDINBUG-492

Moc'ing fails due to syntax error on MSVC 2017

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Not Evaluated Not Evaluated
    • None
    • 2.1.2
    • General
    • None
    • MS Visual Studio 15.4.0

      Qt 5.9.2 msvc2017_64

      The vcxproj file will have a syntax error for any moc command after a project has been opened using the Open Qt Project File (.pro) menu option. If you open up the vcxproj file you will see the Command:

       

      %40echo moc objectheader.h &&
      "$(QTDIR)\bin\moc.exe" ...
      

      The issue is that there is a \r\n at the end of the first line, and when it is put into a command prompt you get:

      C:\> @echo moc objectheader.h &&
      The syntax of the command is incorrect.
      
      C:\>

      It looks like src/qtprojectlib/MocCmdChecker.cs tries to compensate for it in the method SplitIntoCommands on line 115 (snippet below) but it only searches for "&&" and not "&&"

      private static string[] SplitIntoCommands(string cmdLine)
      {
          var cmds = cmdLine.Split(new[] { "&&", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
          var res = new string[cmds.Length];
          for (var i = 0; i < cmds.Length; ++i)
              res[i] = cmds[i].Trim();
          return res;
      }
      

      The workaround for now is to either delete the "&amp;&amp;" from the end of that line (which looks like the intention of the last code snippet) or replace the \r\n with a space.

       

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

            mecfc Miguel Costa
            rtomek Rob Tomek
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes