Skip to content

Style: Add class_db.h includes explicitly#116826

Merged
Repiteo merged 2 commits intogodotengine:masterfrom
Repiteo:style/class-db-explicit-include
Feb 26, 2026
Merged

Style: Add class_db.h includes explicitly#116826
Repiteo merged 2 commits intogodotengine:masterfrom
Repiteo:style/class-db-explicit-include

Conversation

@Repiteo
Copy link
Contributor

@Repiteo Repiteo commented Feb 26, 2026

During yesterday's core meeting, several topics were touched on with regards to the process by which we should be removing implicit includes for the comically-prevalent class_db.h. The current consensus seems to be that it's something that all Object subclasses rely on, so it would result in a fair amount of churn for the codebase when rolling out those changes. Tracking performance changes would also be tricky, as the number of files that actually need the include is hard to get a concrete answer for, even with the two above PRs in isolation (combined might paint a different story).

This stylistic PR is made with the intent of getting the churn itself over with as quickly and painlessly as possible. For every single implementation file that binds in some capacity, this PR adds #include "core/object/class_db.h explicitly. There are zero functional changes as a result of this PR, because every single one of these files requires this include to begin with. As such, this PR similar to #116539 (albeit much wider in scope), where it more clearly spells out the "problem" includes by going against the minimal-include default.

On a somewhat-related note: compatibility include order was brought up during the ClassDB core meeting topic, as it was discovered in #116737 that we cannot simply put class_db.h after *.compat.inc. Ivorforce suggested that we could just drop all those includes to the bottom of the file instead, something that godot-cpp already does. Since I'm already touching literally every single file that has those compatibility includes, as they're only a concept for Object subclass bindings, I tackled their migration in the same pass. This too resulted in zero functional changes, so it's similarly ignored within the same commit. EDIT: In the interest of keeping this PR free of blockers, I've instead implemented the #116737 approach of adding class_db.h includes to the *.compat.inc files instead

@Repiteo Repiteo added this to the 4.x milestone Feb 26, 2026
@Repiteo Repiteo requested review from a team as code owners February 26, 2026 20:46
@Repiteo Repiteo removed the request for review from a team February 26, 2026 20:47
Copy link
Member

@Ivorforce Ivorforce left a comment

Choose a reason for hiding this comment

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

I'm almost surprised to say but I'm fine with the class_db.h explicit include.
It's a great approach: Just add it to all the implementation files of Object subclasses. Makes for a real simple PR, and one that unlocks us from removing the include from headers much easier.

I'm not 100% sure about the .compat.inc. Both positions come with potential downsides: If it's at the start it cannot use the .cpp file's static functions, if it's at the end, the .cpp files cannot use compat functions (though perhaps they shouldn't need to?). Overall I don't have a strong preference for this which is why I haven't made an official proposal to change this so far. Maybe it would be ideal to actually have it be a separate .cpp file altogether, and one that only affects the header by declaring like _bind_compat_functions or something like that. But I'm not sure it's worth the churn to change it at all right now?

Anyway, enough rambling, i'd say it at least needs some separate discussion.

@Repiteo Repiteo modified the milestones: 4.x, 4.7 Feb 26, 2026
@Repiteo
Copy link
Contributor Author

Repiteo commented Feb 26, 2026

If the *.compat.inc are going to serve as a blocker in any capacity atm, then I'll save it for another PR & keep this focused on just the class_db.h includes.

@Repiteo Repiteo force-pushed the style/class-db-explicit-include branch from 4d31f8f to 5b2deb8 Compare February 26, 2026 21:50
@Repiteo Repiteo changed the title Style: Add class_db.h includes explicitly; migrate *.compat.inc includes to bottom of file Style: Add class_db.h includes explicitly Feb 26, 2026
@Repiteo
Copy link
Contributor Author

Repiteo commented Feb 26, 2026

Opted for the #116737 approach instead, where the *.compat.inc files themselves include class_db.h directly. A full revert would have meant more churn down the road when the include-order bug returned, so this nips that in the bud while keeping true to the main intent of this PR: explicit includes for everything requiring class_db.h

@Repiteo Repiteo requested a review from Ivorforce February 26, 2026 21:59
Copy link
Member

@Ivorforce Ivorforce left a comment

Choose a reason for hiding this comment

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

Thanks for adjusting!

@Repiteo Repiteo merged commit f630133 into godotengine:master Feb 26, 2026
20 checks passed
@Repiteo Repiteo deleted the style/class-db-explicit-include branch February 26, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants