Skip to content

Refactor chk to macro with source location#20

Open
GHF wants to merge 1 commit intoSaschaWillems:mainfrom
GHF:refactor/chk-macro
Open

Refactor chk to macro with source location#20
GHF wants to merge 1 commit intoSaschaWillems:mainfrom
GHF:refactor/chk-macro

Conversation

@GHF
Copy link

@GHF GHF commented Jan 19, 2026

Not sure if you might consider this too C++-y but while hacking on the tutorial for macOS, I ran into a lot of different call failures and this really helped track them down.

Prints out source text and location when a chk fails.

Also fixes minor bug of exiting with 0 with chk(false).

Prints out source text and location when a chk fails.

Also fixes minor bug of exiting with 0 with chk(false).
Copilot AI review requested due to automatic review settings January 19, 2026 02:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the chk error checking function into a macro that captures source location information for better debugging, and fixes a bug where chk(false) would exit with code 0 instead of a failure code.

Changes:

  • Converted chk function to a macro that captures source location, file, and line information
  • Added detailed error messages showing where checks fail and what expression was evaluated
  • Fixed bug where boolean check failures would exit with code 0 instead of -1
  • Removed unused <fstream> include and added <source_location> include

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

1 participant