Skip to content

Commit

Permalink
Make lest_expect_abort more portable to non-Windows platforms
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
musicinmybrain committed Jan 10, 2025
1 parent 778597f commit c590a39
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contrib/lest_expect_abort/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions contrib/lest_expect_abort/lest_expect_abort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
#include "lest/lest.hpp"

#include <csetjmp>
#include <cstdio>
#include <cstdlib>

#if _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
#include <fcntl.h>

#if ! defined( lest_NO_SHORT_MACRO_NAMES )
Expand Down
6 changes: 6 additions & 0 deletions contrib/lest_expect_abort/lest_expect_abort_cpp03.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
#include "lest/lest_cpp03.hpp"

#include <csetjmp>
#include <cstdio>
#include <cstdlib>

#if _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
#include <fcntl.h>

#if ! defined( lest_NO_SHORT_MACRO_NAMES )
Expand Down

0 comments on commit c590a39

Please sign in to comment.