Skip to content

Clang could warn about trailing spaces in #include filenames #96064

@zmodem

Description

@zmodem

Consider:

#include "foo.h " // Note: trailing space.

Assuming foo.h exists, the code above will compile on Windows whose filesystem API generally ignores leading and trailing space in filenames. However it will not compile on stricter systems such as Linux.

Maybe Clang should warn? It's niche, but also seems easy to do.

(Yes, we hit this in real code, https://chromium-review.googlesource.com/c/chromium/src/+/5641197)

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerenhancementImproving things as opposed to bug fixing, e.g. new or missing featuregood first issuehttps://github.com/llvm/llvm-project/contribute

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions