Skip to content

Make include detection for old compilers more robust #153

Open
@matthijskooijman

Description

@matthijskooijman

To figure out what libraries a sketch needs, it is processed by the gcc preprocessor, and its error output is analyzed to figure out what header file is missing. Normally, the compiler outputs an error message followed by the actual source line that has the error, like:

/path/to/foo.ino:1:22: fatal error: somefile.h: No such file or directory
 #include <somefile.h>
                      ^

By matching these lines for #include, the missing filename is found.

However, older compilers do not include this source line, but just the error message:

/path/to/foo.ino:1:22: fatal error: somefile.h: No such file or directory

Currently, there is a fallback that splits on a colon, looks for "fatal error" and then returns the next part of the error message as the filename. This seems to work so far, but is also fairly fragile to changes in the error message.

A better approach might be to instead look at the /path/to/foo.ino:1:22 part (which I expect to be more reliable), load the named file, look up the given line number and see if there is any #include in that line. I believe that would be more reliable, and would make the fallback processing more in-line with the normal processing (by scanning for #include).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions