Skip to content

Commit

Permalink
Utility: fix build on FreeBSD and other BSD variants.
Browse files Browse the repository at this point in the history
The _POSIX_C_SOURCE #if was a hopeful attempt, but apparently it didn't
work at all, due to _POSIX_C_SOURCE not being a thing at all unless
explicitly defined by the user. So instead testing for the BSD macros
directly.

Co-authored-by: Yuri Victorovich <yuri@FreeBSD.org>
  • Loading branch information
mosra and yurivict committed Jan 16, 2023
1 parent 3bf6057 commit 8effd9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion doc/corrade-changelog.dox
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ namespace Corrade {
you include @ref Corrade/Utility/DebugStlStringView.h
- Improved error handling in @ref Utility::Path APIs where all APIs now
consistently print an error code and message coming from the system on
failure instead of a generic message or nothing at all
failure instead of a generic message or nothing at all. See also
[mosra/corrade#164](https://github.com/mosra/corrade/issues/164).
- @ref Utility::Path::isDirectory() now follows symlinks on Unix platforms
- @ref Utility::Path::ListFlag::SkipFiles and
@ref Utility::Path::ListFlag::SkipDirectories passed to
Expand Down
4 changes: 3 additions & 1 deletion src/Corrade/Utility/Implementation/ErrorString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ void printErrnoErrorString(Debug& debug, const int error) {
idea. The POSIX variant returns int(0) on success, while the GNU variant
may return a pointer to a statically allocated string instead of filling
the buffer. Sigh. */
#if ((_POSIX_C_SOURCE >= 200112L) && !_GNU_SOURCE) || defined(CORRADE_TARGET_EMSCRIPTEN) || defined(CORRADE_TARGET_APPLE)
/** @todo might want to add CORRADE_TARGET_BSD covering all three variants,
there's no overarching BSD define present on all BSDs :( */
#if ((_POSIX_C_SOURCE >= 200112L) && !_GNU_SOURCE) || defined(CORRADE_TARGET_EMSCRIPTEN) || defined(CORRADE_TARGET_APPLE) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
char string[256];
CORRADE_INTERNAL_ASSERT_OUTPUT(strerror_r(error, string, Containers::arraySize(string)) == 0);
#else
Expand Down

0 comments on commit 8effd9c

Please sign in to comment.