Skip to content

Add strict warning configuration - #132

Merged
cursey merged 5 commits into
mainfrom
strict-warning-flags
Jun 20, 2026
Merged

cursey merged 5 commits into
mainfrom
strict-warning-flags

Conversation

@cursey

@cursey cursey commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add a reusable CMake helper for project warning flags across GCC, Clang, MSVC, and clang-cl.
  • Gate warnings-as-errors behind SAFETYHOOK_WARNINGS_AS_ERRORS, defaulting to enabled when CI is set.
  • Move NOMINMAX handling into private CMake compile definitions for Windows targets.
  • Replace example <print> usage with std::cout for broader standard library compatibility.

Validation

  • MinGW GCC build and tests passed.
  • MSVC build and tests passed.
  • clang-cl build and tests passed.
  • Docker Ubuntu GCC build and tests passed.
  • Docker Ubuntu Clang with libc++ build and tests passed.
  • Verified local non-CI config omits -Werror and CI config includes it.

@cursey
cursey marked this pull request as ready for review June 19, 2026 09:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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; adds SAFETYHOOK_WARNINGS_AS_ERRORS defaulting to CI-enabled.
  • Moves NOMINMAX from source/amalgamation generation into CMake compile definitions for Windows targets.
  • Replaces std::println usage in examples with std::cout output.

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.

Comment thread src/os.windows.cpp
Comment thread example/multiple.cpp
@cursey
cursey merged commit f44cc07 into main Jun 20, 2026
22 checks passed
@cursey
cursey deleted the strict-warning-flags branch June 20, 2026 01:22
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.

2 participants