Add strict warning configuration - #132
Merged
Merged
Conversation
cursey
marked this pull request as ready for review
June 19, 2026 09:39
There was a problem hiding this comment.
Pull request overview
Adds a centralized CMake helper to apply consistent “strict warnings” across targets, with warnings-as-errors controlled by a new SAFETYHOOK_WARNINGS_AS_ERRORS option that defaults to ON in CI environments. Also refactors Windows NOMINMAX handling and updates examples to avoid reliance on <print>.
Changes:
- Introduces
safetyhook_enable_strict_warnings()and applies it to library, tests, module, and examples; addsSAFETYHOOK_WARNINGS_AS_ERRORSdefaulting to CI-enabled. - Moves
NOMINMAXfrom source/amalgamation generation into CMake compile definitions for Windows targets. - Replaces
std::printlnusage in examples withstd::coutoutput.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| CMakeLists.txt | Adds warnings helper and CI-defaulted warnings-as-errors option. |
| src/CMakeLists.txt | Applies strict warnings helper and sets Windows NOMINMAX define. |
| test/CMakeLists.txt | Applies strict warnings helper to test targets; sets NOMINMAX for amalgamated test on Windows. |
| module/CMakeLists.txt | Enables strict warnings for the module target. |
| src/os.windows.cpp | Removes in-source NOMINMAX define prior to including Windows headers. |
| amalgamate.py | Removes injected NOMINMAX from the generated amalgamated source. |
| include/safetyhook/vmt_hook.hpp | Suppresses GCC -Wattributes around thiscall() template. |
| include/safetyhook/inline_hook.hpp | Suppresses GCC -Wattributes around thiscall() / unsafe_thiscall() templates. |
| example/CMakeLists.txt | Enables strict warnings for example targets. |
| example/minimal.cpp | Replaces <print>/std::println with std::cout. |
| example/multiple.cpp | Replaces <print>/std::println with std::cout. |
| example/midhook.cpp | Replaces <print>/std::println with std::cout. |
| example/threadsafe.cpp | Replaces <print>/std::println with std::cout. |
| example/vmthook.cpp | Replaces <print>/std::println with std::cout. |
| example/module.cpp | Replaces <print>/std::println with std::cout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
# Conflicts: # module/CMakeLists.txt
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
SAFETYHOOK_WARNINGS_AS_ERRORS, defaulting to enabled whenCIis set.NOMINMAXhandling into private CMake compile definitions for Windows targets.<print>usage withstd::coutfor broader standard library compatibility.Validation
-Werrorand CI config includes it.