Skip to content

Commit c590a39

Browse files
Make lest_expect_abort more portable to non-Windows platforms
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`.
1 parent 778597f commit c590a39

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

contrib/lest_expect_abort/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Please note the following:
1515

1616
Dependencies
1717
------------
18-
*lest_expect_abort* requires headers `io.h` and `fcntl.h` for suppression of messages from `assert`.
18+
*lest_expect_abort* requires header `fcntl.h` and `io.h` (Windows) or `unistd.h` (otherwise) for suppression of messages from `assert`.
1919

2020

2121
Assertion macros

contrib/lest_expect_abort/lest_expect_abort.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
#include "lest/lest.hpp"
1010

1111
#include <csetjmp>
12+
#include <cstdio>
13+
#include <cstdlib>
1214

15+
#if _WIN32
1316
#include <io.h>
17+
#else
18+
#include <unistd.h>
19+
#endif
1420
#include <fcntl.h>
1521

1622
#if ! defined( lest_NO_SHORT_MACRO_NAMES )

contrib/lest_expect_abort/lest_expect_abort_cpp03.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
#include "lest/lest_cpp03.hpp"
1010

1111
#include <csetjmp>
12+
#include <cstdio>
13+
#include <cstdlib>
1214

15+
#if _WIN32
1316
#include <io.h>
17+
#else
18+
#include <unistd.h>
19+
#endif
1420
#include <fcntl.h>
1521

1622
#if ! defined( lest_NO_SHORT_MACRO_NAMES )

0 commit comments

Comments
 (0)