Skip to content

[style] Use clang-format to sort includes #9482

@adonis0147

Description

@adonis0147

Search before asking

  • I had searched in the issues and found no similar issues.

Description

Before the commit #9305 , if we use clang-format to format our codebase, the clang-format sorts the includes.

#9305 claims that there are some compilation errors occurring after we sort the includes in our codebase. Generally speaking, it is right due to the conditional includes (some includes must be put after others, see google code style). However, the number of these exceptions is small, we can treat them case by case.

There are some approaches to handle these exceptions:

  1. Exclude the whole file - Adding it to .clang-format-ignore
  2. Exclude some regions in the file - Please refer to Clang-Format Style Options

All in all, it is very helpful if we can unify the order of includes. After investigation, the compilation errors was caused by be/src/service/brpc.h. In brpc.h, the service/brpc_conflict.h must be included first.

Solution

  1. Revert the setting of .clang-format
  2. Fix the compilation errors.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

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