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

Preprocessor can't find computed includes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • Qt Creator 4.15.2
    • C/C++/Obj-C++ Support
    • None
    • Linux/X11

    Description

      Code example:

      #define INC_HDR(hdr) <hdr>
      #include INC_HDR(stdio.h)
      void main() { }

      Result (in code editor):

      • orange underline at line 2
      • when hovering over it, message "stdio.h: No such file or directory"

      #include <stdio.h> certainly works fine, and the project can be built in both cases (with or w/o using INC_HDR macro).

      The reason seems to be somewhere in src/libs/cplusplus/pp-engine.cpp (to be more specific, in void Preprocessor::synchronizeOutputLines() method), that appends newlines during expansion of "INC_HDR(stdio.h)" into something like "\n<\nstdio.h>". And it's the "\nstdio.h" file that cannot be found and finally causes "messageNoSuchFile" at void CppSourceProcessor::sourceNeeded() method (see src/plugins/cpptools/cppsourceprocessor.cpp).

      Unfortunately, i'm not deeply familiar with things like C++ tokenization, AST and so on, so any help or advice would be very useful.

      Attachments

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

        Activity

          People

            kandeler Christian Kandeler
            d_garry Igor R
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes