Make public headers self-contained and stop relying on PCH - #40
Open
TrueBrain wants to merge 1 commit into
Open
Conversation
Every public header now compiles on its own, and every source states its own dependencies rather than inheriting them (implicit) from StdAfx.h. Additionally, extend the CI to check if compiling without PCH still works. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
TrueBrain
force-pushed
the
include-self-containment
branch
from
August 22, 2026 09:50
2415707 to
16df0e4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Initially I wanted to make an issue first, to talk this over. But code speaks louder than any words, so I ended up making this PR instead. But this PR is much more a "do you want to go in this direction?" question that should have been asked in an issue.
Sorry :(
When compiling this (and many of the other carbon) repositories on Linux, you run into the issue that a bunch of include headers are missing. And this totally make sense, as these repositories use PCH with
<windows.h>. Which means on Windows, a ton of system headers are added without people realizing (aswindows.his a terrible header in this regard).Building on MacOS will tell about most: but not all. And this is because GCC has a different opinion about system headers than others do: it minimizes them as much as it can. Famously, since GCC 13 they removed the inclusion of
cstdintby their headers. To take this as example, it means:<windows.h>will transitively include this header.So we run into compiler-errors on Linux. Fixing this can be done in several ways, but it also highlights a bigger problem: something that works on one platform, fails on another. And those can be annoying to deal with after-the-fact.
While delving into this further, I noticed a bit of a more tricky problem to deal with:
No file in the "include" folder includes
StdAfx.h, but some do depend on its context via PCH. This means there is a knock-on effect through all repositories that depend oncore: they all need a PCH to at least cover the include files in the PCH ofcore. And that can be unexpected.So this PR sets out to fix these issues:
Additionally, I let Claude write some code for the CI, so it covers that non-PCH keeps on building. Just to prevent regression on this front.
After this PR you end up with public-headers that don't implicitly need a PCH to contain some includes. In other words: this fixes that silently the
StdAfx.hleaked into the public headers, althoughStdAfx.hitself wasn't made public. This also means that after this PR PCH becomes a compile-performance optimization again, and not a dependency of its own.That all said and done, the actual requirement to build on Linux is a much smaller change: https://github.com/carbonengine/core/compare/main...TrueBrain:carbonengine-core:push-xkzzrvtkskxx?expand=1. I am also fine if that is the route to take.
PS: of course if this PR is accepted, I can do the same work on other repositories that have the same issue. About 50% of them currently fail on missing headers, in different degrees.
PPS: the no-PCH build most likely fails on MacOS till #41 lands.
AI assistance disclosure
Claude wrote the code; I instructed what I wanted to achieve. Verified it is matching up with my expectations.
Type of change
Linked issue (optional)
What changed
Testing
Platforms tested
Screenshots / captures
Checklist
Full disclosure: I am employed by Fenris Creations, although I have no involvement with the Carbon project. I work on this in my free time under my own name.