Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-27117

cppcheck considers .h header files to be C style if qt_add_qml_module is used in CMake project

    XMLWordPrintable

Details

    • Windows
    • 498418bbc9 (qt-creator/qt-creator/8.0) 498418bbc9 (qt-creator/qt-creator/master) 498418bbc9 (qt-creator/tqtc-qt-creator/8.0)

    Description

      When using CMake and the experimental cppcheck plugin, if the CMake project file uses qt_add_qml_module, .h header files are considered C style.

      .../testobject.h
      .../testobject.h:6: Code 'classTestObject:' is invalid C code. Use --std or --language to configure the language.
      

      Doing the suggested --std or --language flags do not change anything. Following warning is shown in the Qt Creator, but selecting the suggested parser output for C++ does not help either. See attached image.

      Note: Multiple parse contexts are available for this file. Choose the preferred one from the editor toolbar.
      

      This can be reproduced with the for example the "adding" Qt example (<examples>\qml\referenceexamples\adding). In that project the culprit lines in CMakeLists. are:

      qt_add_qml_module(adding
          URI People
          VERSION 1.0
          QML_FILES example.qml
          NO_RESOURCE_TARGET_PATH
      )
      

      Attachments

        1. qtcreatorbug27117.png
          qtcreatorbug27117.png
          15 kB
        2. qtc-cppcheck.png
          qtc-cppcheck.png
          79 kB
        3. qt6emptyproject.zip
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            cadam Cristian Adam
            jussi_witick Jussi Witick
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes