Skip to content

CI: Add WinAPI header compatibility workflow#2630

Merged
annihilatorq merged 17 commits into
stephenberry:mainfrom
annihilatorq:ci/windows-header-compatibility-workflow
Jun 18, 2026
Merged

CI: Add WinAPI header compatibility workflow#2630
annihilatorq merged 17 commits into
stephenberry:mainfrom
annihilatorq:ci/windows-header-compatibility-workflow

Conversation

@annihilatorq

Copy link
Copy Markdown
Collaborator

This workflow contains a pretty simple check, which will ultimately eliminate the need to worry about guarding std::min/max and std::numeric_limits<T>::min/max, ensure naming conventions that do not conflict with Windows definitions, and address other minor issues that might occasionally slip through code reviews and make it into the main branch. This workflow will simply fail in the event of a forgotten guard or a conflict. The code will still need to use guards, but if this is forgotten, it won't pass CI

The workflow deliberately creates a poor environment for the library by generating a messy translation unit in a typical Windows project, where NOMINMAX, WIN32_LEAN_AND_MEAN, and NOGDI are not defined. The workflow also ensures that guard fixes via #undef of any Windows defines do not accidentally slip into the main branch, so as not to break a user's project whose code may rely on one of these defines.

DELETE is a special case in this workflow, as glaze/net actively uses #undef DELETE, so the presence of this define is not checked after including the Glaze header.

I used recursion and included each header separately instead of including the umbrella header (glaze.hpp), since I noticed that umbrella headers do not include the entire public Glaze API headers (is this by design, or does it require a fix?)

@stephenberry

Copy link
Copy Markdown
Owner

The workflow deliberately creates a poor environment for the library by generating a messy translation unit in a typical Windows project

This is a great idea!

@stephenberry

Copy link
Copy Markdown
Owner

I noticed that umbrella headers do not include the entire public Glaze API headers (is this by design, or does it require a fix?)

Glaze has so many features that I've been moving more and more away from umbrella headers. It's better for headers like "glaze/json.hpp" to handle the most common JSON utilities, but lots of headers are just for special use cases and it reduces compilation times by not including all features under huge umbrella headers.

When we finally get C++20 modules we should be able to have everything under a single module, or a few umbrella modules.

@annihilatorq

Copy link
Copy Markdown
Collaborator Author

This is a great idea!

Thanks, but it seems like the idea of building a separate target for each include was a bad one, since the workflow ended up taking too long, and it looks like I might have made some kind of mistake because the build is failing. I'll fix it when I wake up, since I was just about to go to sleep 😁

Comment thread .github/workflows/windows-header-compatibility.yml Outdated
@annihilatorq annihilatorq force-pushed the ci/windows-header-compatibility-workflow branch from 92fd9d2 to ad7feb2 Compare June 17, 2026 00:13
@annihilatorq

Copy link
Copy Markdown
Collaborator Author

The workflow is finally working as intended. The test run in which I removed the guard around std::numeric_limits<T>::max caught the error as expected (I cleared the history of that commit via rebase). I'll try to clean up the CMake script before the merge and make it easier to add headers or directories to the list for the WIN32_LEAN_AND_MEAN target, but functionally, the current version is already fully operational.

Currently, some headers, for example - any header from glaze/net, need to be built under WIN32_LEAN_AND_MEAN because the errors within them come from external dependencies (asio, erlang) that are outside of Glaze scope.
In such case, all we can do is try to provide user with better diagnostics (#2635)

@DockedFerret800

Copy link
Copy Markdown
Contributor

The final decision regarding this is up to Stephen; however, the current workflow looks significantly unmanageable to me. I’d suggest creating a separate file for in the CMake folder, for example /cmake/ci/ and include from it. This would make things much cleaner. I would also use run-vcpkg action for the vcpkg installation step to leverage vcpkg binary caching and reduce CI runtime, although this is just a nit, given that the current step doesn’t take much time, so this can be omitted.

@annihilatorq

Copy link
Copy Markdown
Collaborator Author

The final decision regarding this is up to Stephen; however, the current workflow looks significantly unmanageable to me.

Yes, I was planning to refactor it today, as I mentioned in my previous comment. Yesterday, I made a lot of fixes to ensure it worked correctly, which cluttered up the CMake code with these quick patches.

As for adding run-vcpkg, I think Stephen would be against it, based on this comment, but I’m not sure if it makes sense to try to speed things up, considering that the workflow runs in ~2-3 minutes, while the longest workflows take about 20-30 minutes.

@DockedFerret800

Copy link
Copy Markdown
Contributor

Yeah, this surely can be omitted in this case 👍🏻

@annihilatorq

Copy link
Copy Markdown
Collaborator Author

I think everything is ready for the merge now, pending your review @stephenberry

@DockedFerret800, could I get your thoughts on the current workflow structure?

@annihilatorq annihilatorq requested review from DockedFerret800 and stephenberry and removed request for DockedFerret800 June 18, 2026 00:51

@DockedFerret800 DockedFerret800 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, just a few small nits. 👍🏻

Comment thread .github/workflows/windows-header-compatibility.yml Outdated
Comment thread .github/workflows/windows-header-compatibility.yml Outdated
Comment thread .github/workflows/windows-header-compatibility.yml
Comment thread .github/workflows/windows-header-compatibility.yml Outdated
Comment thread .github/workflows/windows-header-compatibility.yml Outdated
annihilatorq and others added 3 commits June 18, 2026 18:45
Co-authored-by: Yan Romao <DockedFerret800@outlook.com>
Co-authored-by: Yan Romao <DockedFerret800@outlook.com>
Co-authored-by: Yan Romao <DockedFerret800@outlook.com>
@packit-as-a-service

Copy link
Copy Markdown

@annihilatorq annihilatorq merged commit 44c0035 into stephenberry:main Jun 18, 2026
54 of 55 checks passed
@stephenberry

Copy link
Copy Markdown
Owner

Thanks for this! It looks good!

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