Closed CrustyAuklet closed 2 years ago
strerror_r
is not racy unlike strerror
so I can't replace as you suggest. Can you suggest an alternative fix?
providing a definition works with GNU extensions on and off.
// ensure definition of strerror_r exists when GNU extensions off
char *strerror_r (int, char *, size_t);
#include <outcome/outcome-experimental.hpp>
Other than that the only function available
in all cases is char * _strerror_r (struct _reent *, int, int, int *);
. This appears to be the functions that all the other
flavors of strerror
are implemented against.
char* strerror_r (int errnum, char *buffer, size_t n)
{
char *error = _strerror_r (_REENT, errnum, 1, NULL);
if (strlen (error) >= n)
return error;
return strcpy (buffer, error);
}
Can you check if PR #49 fixes your problem?
Works in my project, thanks!
I'm using experimental outcome in a bare metal ARM cortex-m project. The code is using C++20 and I wanted to change it to
-std=c++20
instead of-std=gnu++20
but this causes Outcome to no longer compile.Compiler: arm-none-eabi-11.3.1-rel1 (latest ARM provided toolchain) arch: ARM-v8M-baseline (M23)
I traced the issue to the following snippet: https://github.com/ned14/outcome/blob/94035926674a6db75152a98981a400f074c91534/single-header/outcome-experimental.hpp#L9066-L9081
The code in newlib looks like this:
With GNU extensions on the function
int strerror_r (int, char *, size_t);
is available, but with GNU extensions off we are only left withchar* _strerror_r (struct _reent *, int, int, int *);
I fixed this in my vendored copy by adding an additional macro branch based on
__GNU_VISIBLE