Skip to content

Commit b5d95ba

Browse files
committed
Fix probable compile errors due to redefining macros
- The macro _POSIX_C_SOURCE may be defined by compilers, a value incompatible with that specified in the source. This may trigger compiler warnings / errors depending on the configuration. We undefine it and redefine it to the value that we want. - The macro _GNU_SOURCE may be undefined in the future, depending on which direction ola development progresses. It is only undefined when the macro is present to avoid future errors.
1 parent 6fa41db commit b5d95ba

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

olad/Strerror_r.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,16 @@
2424

2525
// Required for string.h to declare the standards-compliant version of
2626
// strerror_r(), when compiling under glibc. Must come before the inclusion
27-
// of string.h
27+
// of string.h.
28+
// These are conditional to avoid errors when not compiling with glibc, or
29+
// when compiling with a compiler that does not define _POSIX_C_SOURCE.
30+
#ifdef _GNU_SOURCE
2831
#undef _GNU_SOURCE
32+
#endif
33+
34+
#ifdef _POSIX_C_SOURCE
35+
#undef _POSIX_C_SOURCE
36+
#endif
2937
#define _POSIX_C_SOURCE 200112L
3038

3139
#include <string.h>

0 commit comments

Comments
 (0)