Skip to content

[core] Add missing standard library includes - #23227

Merged
guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:paramfunctor-missing-includes
Sep 2, 2026
Merged

[core] Add missing standard library includes#23227
guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:paramfunctor-missing-includes

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

Several files use std::cout/std::cerr or std::ostream without including or themselves, and only compile because Math/ParamFunctor.h transitively pulls in .

Add the includes where they are used, so that ParamFunctor.h can drop its own include without breaking these translation units.

Where a file already listed standard library headers before its ROOT includes, reorder them to follow the convention of ROOT headers first, then other libraries, then the standard library.

FYI, @hageboeck

Several files use std::cout/std::cerr or std::ostream without including
<iostream> or <ostream> themselves, and only compile because
Math/ParamFunctor.h transitively pulls in <iostream>.

Add the includes where they are used, so that ParamFunctor.h can drop its
own <iostream> include without breaking these translation units.

Where a file already listed standard library headers before its ROOT
includes, reorder them to follow the convention of ROOT headers first,
then other libraries, then the standard library.

@ferdymercury ferdymercury left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Did you try using

misc-include-cleaner when running clang-tidy?
(to check for all occurrences.)

There's also include-what-you-use

@dpiparo

dpiparo commented Sep 2, 2026

Copy link
Copy Markdown
Member

Maybe a word of caution about `include-what-you-use. Once it was tried for ROOT, and the results obtained on macOS were not compiling on Linux and viceversa. It was a while ago, and another look could demonstrate that the tool drastically improved in that respect...

@guitargeek

Copy link
Copy Markdown
Contributor Author

Thanks for the comments! I don't want to go into cleaning includes in general though. This is just a small PR that well out of a refactor:

@ferdymercury

Copy link
Copy Markdown
Collaborator

macOS were not compiling on Linux and viceversa

maybe it's also about gcc vs clang ?

the tool drastically improved in that respect...

I think the tool supports multi-platform input, meaning if platform A requires header X and platform B does not require it, it won't suggest you to remove it. But you still have to find a way to pass it that information since the tool cannot know how other platforms look like.

GoogleAI suggests this GH action iwyu.yml.txt which could me modified to use instead our own CI platforms and it could run once a week or whatever.

@guitargeek
guitargeek merged commit d7ae00c into root-project:master Sep 2, 2026
13 of 27 checks passed
@guitargeek
guitargeek deleted the paramfunctor-missing-includes branch September 2, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants