-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathStrError_R_XSI.cpp
More file actions
51 lines (44 loc) · 1.74 KB
/
StrError_R_XSI.cpp
File metadata and controls
51 lines (44 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* StrError_R_XSI.cpp
* Definition of strerror_r() that is XSI-compliant.
* This extra file is required because the header declaring the symbols
* for the C++ string library conflicts with the macros used to expose
* the XSI-compliant declaration of strerror_r().
* Copyright (C) 2018 Shenghao Yang
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif // HAVE_CONFIG_H
// Required for string.h to declare the standards-compliant version of
// strerror_r(), when compiling under glibc. Must come before the inclusion
// of string.h.
// These are conditional to avoid errors when not compiling with glibc, or
// when compiling with a compiler that does not define _POSIX_C_SOURCE.
// See strerror(3) as to why the macros are defined this way.
#ifdef _GNU_SOURCE
#undef _GNU_SOURCE
#endif
#ifdef _POSIX_C_SOURCE
#undef _POSIX_C_SOURCE
#endif
#define _POSIX_C_SOURCE 200112L
#include <string.h>
namespace ola {
int StrError_R_XSI(int errnum, char* buf, size_t buflen) {
return strerror_r(errnum, buf, buflen);
}
} // namespace ola