Skip to content

Contradiction between C++ styleguide and cpplint regarding transitive includes #757

Closed as not planned
@geoffviola

Description

@geoffviola

This issue comes from cpplint/cpplint#218

The Google C++ Style Guide states that

Do not rely on transitive inclusions. This allows people to remove no-longer-needed #include statements from their headers without breaking clients. This also applies to related headers - foo.cc should include bar.h if it uses a symbol from it even if foo.h includes bar.h.

The second part about including the direct dependencies in the source file regardless of the corresponding header, contradicts with cpplint. When cpplint is run on a source file, it counts the includes in its corresponding header file as included.

The policy is that if you #include something in foo.h you don't need to
include it again in foo.cc. Here, we will look at possible includes.

Which rule should be followed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions