Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix for w64devkit and mingw
  • Loading branch information
DannyDaemonic committed May 18, 2023
commit 649098737de22c78e990674ce9e25caa61444b00
10 changes: 6 additions & 4 deletions examples/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ void sigint_handler(int signo) {
}
}
#endif
#if defined (_WIN32)
BOOL console_ctrl_handler(DWORD ctrl_type) {
return (ctrl_type == CTRL_C_EVENT) ? (sigint_handler(SIGINT), true) : false;
}
#endif

int main(int argc, char ** argv) {
gpt_params params;
Expand Down Expand Up @@ -241,10 +246,7 @@ int main(int argc, char ** argv) {
sigint_action.sa_flags = 0;
sigaction(SIGINT, &sigint_action, NULL);
#elif defined (_WIN32)
auto console_ctrl_handler = [](DWORD ctrl_type) -> BOOL {
return (ctrl_type == CTRL_C_EVENT) ? (sigint_handler(SIGINT), true) : false;
};
SetConsoleCtrlHandler(static_cast<PHANDLER_ROUTINE>(console_ctrl_handler), true);
SetConsoleCtrlHandler(console_ctrl_handler, true);
#endif

fprintf(stderr, "%s: interactive mode on.\n", __func__);
Expand Down