From eeaaaf3b9bde030aeeba6ebd50f032a30c31016f Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Wed, 17 Aug 2022 12:54:22 +0100 Subject: [PATCH] Make use of Win32 functions conditional on _WIN32, not _MSC_VER. Using _MSC_VER here means that the choice of signal() versus SetConsoleCtrlHandler depends on the compiler being used, rather than the OS being targeted. When built with MinGW rather than MSVC, this happens to work because MinGW's signal emulation is used, but that emulation is quite limited. Instead, be consistent and use the Win32 API when building for that platform, regardless of compiler. Note that if building for Cygwin, _WIN32 is not defined and POSIX APIs are used. --- host/hackrf-tools/src/hackrf_transfer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/host/hackrf-tools/src/hackrf_transfer.c b/host/hackrf-tools/src/hackrf_transfer.c index f39f9517..98ff6044 100644 --- a/host/hackrf-tools/src/hackrf_transfer.c +++ b/host/hackrf-tools/src/hackrf_transfer.c @@ -609,7 +609,7 @@ static void usage() static hackrf_device* device = NULL; -#ifdef _MSC_VER +#ifdef _WIN32 BOOL WINAPI sighandler(int signum) { if (CTRL_C_EVENT == signum) { @@ -1041,7 +1041,7 @@ int main(int argc, char** argv) fwrite(&wave_file_hdr, 1, sizeof(t_wav_file_hdr), file); } -#ifdef _MSC_VER +#ifdef _WIN32 SetConsoleCtrlHandler((PHANDLER_ROUTINE) sighandler, TRUE); #else signal(SIGINT, &sigint_callback_handler);