From 03ffa52bc8e855462318194638f108d2a280e9f4 Mon Sep 17 00:00:00 2001 From: Ben Beasley Date: Fri, 10 Jan 2025 07:45:36 -0500 Subject: [PATCH] Make lest_expect_abort more portable to non-Windows platforms (#79, thanks @musicinmybrain) Unconditionally include `cstdio` for `fflush` and friends, and `cstdlib` for `abort`. When `_WIN32` is not defined, include `unistd.h` instead of `io.h` for `dup` and `dup2`. --- contrib/lest_expect_abort/Readme.md | 2 +- contrib/lest_expect_abort/lest_expect_abort.hpp | 6 ++++++ contrib/lest_expect_abort/lest_expect_abort_cpp03.hpp | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/contrib/lest_expect_abort/Readme.md b/contrib/lest_expect_abort/Readme.md index 787250b..f52b31b 100644 --- a/contrib/lest_expect_abort/Readme.md +++ b/contrib/lest_expect_abort/Readme.md @@ -15,7 +15,7 @@ Please note the following: Dependencies ------------ -*lest_expect_abort* requires headers `io.h` and `fcntl.h` for suppression of messages from `assert`. +*lest_expect_abort* requires header `fcntl.h` and `io.h` (Windows) or `unistd.h` (otherwise) for suppression of messages from `assert`. Assertion macros diff --git a/contrib/lest_expect_abort/lest_expect_abort.hpp b/contrib/lest_expect_abort/lest_expect_abort.hpp index a80fc35..f9cd7dc 100644 --- a/contrib/lest_expect_abort/lest_expect_abort.hpp +++ b/contrib/lest_expect_abort/lest_expect_abort.hpp @@ -9,8 +9,14 @@ #include "lest/lest.hpp" #include +#include +#include +#if _WIN32 #include +#else +#include +#endif #include #if ! defined( lest_NO_SHORT_MACRO_NAMES ) diff --git a/contrib/lest_expect_abort/lest_expect_abort_cpp03.hpp b/contrib/lest_expect_abort/lest_expect_abort_cpp03.hpp index 2da593d..1e58820 100644 --- a/contrib/lest_expect_abort/lest_expect_abort_cpp03.hpp +++ b/contrib/lest_expect_abort/lest_expect_abort_cpp03.hpp @@ -9,8 +9,14 @@ #include "lest/lest_cpp03.hpp" #include +#include +#include +#if _WIN32 #include +#else +#include +#endif #include #if ! defined( lest_NO_SHORT_MACRO_NAMES )