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

C headers with extern "C" doesn't parse correctly with clang-backend and GCC

    XMLWordPrintable

Details

    Description

      When GCC is selected as the compiler, the code

      #ifdef __cplusplus
      extern "C"
      {
      #endif
      

      will cause a parser error in clang-backend, causing semantic highlighting for the header to completely fail. (i.e. only preprocessor, comments, and primitives are highlighted, not user types, functions, etc.) If the compiler is switched to Clang the backend works correctly. In case it's version dependent, I'm running GCC 8.2. It appears to detect that it's C code for the header, but thinks that __cplusplus is defined.

      Error encountered with GCC:

       

      Works properly with Clang:

       

      I'm using CMake to generate the project.

      Attachments

        1. clang.png
          clang.png
          6 kB
        2. context.png
          context.png
          35 kB
        3. gcc.png
          gcc.png
          11 kB
        4. test.tar.gz
          0.4 kB

        Issue Links

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

          Activity

            People

              kosjar Nikolai Kosjar
              akb825 Aaron Barany
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes