google / google/styleguide

Clarify if case should impact C++ style's #include order

Open
#602 0 comments 0 reactions 0 assignees View on GitHub
lang:cpp
Dominant language
HTML
Stars
39.6k
Forks
12.9k
Avg merge
42m
Merged PRs (30d)
15

Description

https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes specifies

> Within each section the includes should be ordered alphabetically.

I read this to be case insensitive, but have colleagues who disagree with this reading. This is typically not an issue, but can be if third party headers do not use all lower case, or in downstream users of the style (such as Mozilla's). Since programmatic tools to do ordering will often consider case when ordering, it would be useful to not have any ambiguity here.

An example of where this matters using a fictional third party lib with the following includes
```
#include "third_party/cat_herder/Cat.h"
#include "third_party/cat_herder/cat_parser/CatRunIterator.h"
#include "third_party/cat_herder/Claw.h"
```

If case is ignored, the above ordering is correct. However, if case is important, then automated ordering will prefer

```
#include "third_party/cat_herder/Cat.h"
#include "third_party/cat_herder/Claw.h"
#include "third_party/cat_herder/cat_parser/CatRunIterator.h"
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.