Skip to content

[libc] convert preprocessor includes to "" for other libc sources #83210

Closed
@nickdesaulniers

Description

@nickdesaulniers

Forking the discussion from #83199 (comment).

all the #includes in /include/ for things in llvm-libc-types or llvm-libc-macros currently use <>. It may be worthwhile to change this, but that should probably be one cleanup patch.

So we're pretty inconsistent in our use of #include preprocessor statement wrt <> vs "". I think we should move to the convention (and document it in our coding style):

  • If the .h file is part of our sources, use ""
  • If the .h file is NOT part of our sources, use <>

https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html is helpful, particularly:

By default, the preprocessor looks for header files included by the quote form of the directive #include "file" first relative to the directory of the current file, and then in a preconfigured list of standard system directories. For example, if /usr/include/sys/stat.h contains #include "types.h", GCC looks for types.h first in /usr/include/sys, then in its usual search path.

For the angle-bracket form #include , the preprocessor’s default behavior is to look only in the standard system directories.

The most commonly-used option is -Idir, which causes dir to be searched after the current directory (for the quote form of the directive) and ahead of the standard system directories.

Then I think that will help us refine our clang-tidy lint for this: #82695

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions