Coder Social home page Coder Social logo

Comments (3)

mosra avatar mosra commented on May 24, 2024 1

Ah, that's a bit sad. I added all three in 8effd9c.

Thanks for reporting this, and thanks for maintaining the Corrade/Magnum packages as well :)

from corrade.

mosra avatar mosra commented on May 24, 2024

Hmm, that's strange, because I have a preprocessor branch that is attempting to select the right variant:

#if ((_POSIX_C_SOURCE >= 200112L) && !_GNU_SOURCE) || defined(CORRADE_TARGET_EMSCRIPTEN) || defined(CORRADE_TARGET_APPLE)
char string[256];
CORRADE_INTERNAL_ASSERT_OUTPUT(strerror_r(error, string, Containers::arraySize(string)) == 0);
#else
char buffer[256];
const char* const string = strerror_r(error, buffer, Containers::arraySize(buffer));
#endif

Man pages tell me that _POSIX_C_SOURCE >= 200112L) && !_GNU_SOURCE is the expression to check, but maybe _POSIX_C_SOURCE isn't defined by BSD implicitly? (I have to admit my knowledge is very sparse in this area. ๐Ÿ˜…) To be clear, I didn't want to #define _POSIX_C_SOURCE myself to any value to prevent unexpected ABI issues, just wanted to detect which function is actually available.

So, given that I already have to check for Apple and Emscripten explicitly anyway, should I check for BSD this way as well? I.e., would the following work? Is BSD the right define that covers FreeBSD, OpenBSD and others?

diff --git a/src/Corrade/Utility/Implementation/ErrorString.cpp b/src/Corrade/Utility/Implementation/ErrorString.cpp
index 675a6a9e3..66743901f 100644
--- a/src/Corrade/Utility/Implementation/ErrorString.cpp
+++ b/src/Corrade/Utility/Implementation/ErrorString.cpp
@@ -60,7 +60,7 @@ 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)
+    #if ((_POSIX_C_SOURCE >= 200112L) && !_GNU_SOURCE) || defined(CORRADE_TARGET_EMSCRIPTEN) || defined(CORRADE_TARGET_APPLE) || defined(BSD)
     char string[256];
     CORRADE_INTERNAL_ASSERT_OUTPUT(strerror_r(error, string, Containers::arraySize(string)) == 0);
     #else

Thanks in advance for testing this patch!

from corrade.

yurivict avatar yurivict commented on May 24, 2024

The patch doesn't work, but it works when defined (__FreeBSD__) is used.

I just verified - no generic BSD define is present in the C++ compiler on FreeBSD:

$ c++ -dM -E - < /usr/include/time.h | grep -i BSD
#define __BSD_VISIBLE 1
#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
#define __FreeBSD__ 13
#define __FreeBSD_cc_version 1300010
#define __VERSION__ "FreeBSD Clang 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386ae247c)"

Only the __FreeBSD__ is usable.
Likewise, __OpenBSD__ and __NetBSD__ are defined on those systems.

from corrade.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.