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

Clang: "Unterminated conditional directive" error marker on circular includes

    XMLWordPrintable

Details

    • c12b012bb7465299490cf93c2ae90499a5c417d5 (clang/clang/release_80-based) e37a2ef5aa162dba9e221ac2cfa4b7e036cb0950 (clang/llvm-project/release_80-based)

    Description

      Edit: this happens when two include files include each other and include guards are used. It does not happen with #pragma once. Please see comment further down for minimal example

      In one very specific case, Qt Creator incorrectly highlights and shows an error when using nested conditional directives.

      Error shown:

      #ifndef COMMON_H    // <-- unterminated conditional directive
      #define COMMON_H
      
      #include <cstdint>
      
      #ifdef ISSERVER
      
      #include <QSqlQuery>
      #include <log.h>
      
      #endif
      
      // ...
      
      namespace Common {
      
      // ...
      
      #ifdef ISSERVER
      
      // ...
      
      #endif // ISSERVER
      
      }
      
      #endif // COMMON_H
      

      No error:

      #ifndef COMMON_H
      #define COMMON_H
      
      #include <cstdint>
      
      #ifdef ISSERVER
      
      #include <QSqlQuery>
      //#include <log.h>  // <-- commented
      
      #endif
      
      // ...
      
      namespace Common {
      
      // ...
      
      #ifdef ISSERVER
      
      // ...
      
      #endif // ISSERVER
      
      }
      
      #endif // COMMON_H
      
      #pragma once   // <-- added
      
      #ifndef COMMON_H
      #define COMMON_H
      
      #include <cstdint>
      
      #ifdef ISSERVER
      
      #include <QSqlQuery>
      #include <log.h>
      
      #endif
      
      // ...
      
      namespace Common {
      
      // ...
      
      #ifdef ISSERVER
      
      // ...
      
      #endif // ISSERVER
      
      }
      
      #endif // COMMON_H 
      

      Attachments

        Issue Links

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

          Activity

            People

              kosjar Nikolai Kosjar
              maxwell175 Maxwell Dreytser
              Votes:
              9 Vote for this issue
              Watchers:
              17 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: