4 * ISO-C standard header, with MSVC compatible extensions.
8 * Written by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
9 * Copyright (C) 1997-2000, 2002-2004, 2007, 2009, 2015-2017,
13 * Permission is hereby granted, free of charge, to any person obtaining a
14 * copy of this software and associated documentation files (the "Software"),
15 * to deal in the Software without restriction, including without limitation
16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 * and/or sell copies of the Software, and to permit persons to whom the
18 * Software is furnished to do so, subject to the following conditions:
20 * The above copyright notice, this permission notice, and the following
21 * disclaimer shall be included in all copies or substantial portions of
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
30 * DEALINGS IN THE SOFTWARE.
34 #pragma GCC system_header
37 /* All MinGW system headers must include this...
42 /* ISO-C requires this header to expose definitions for NULL and size_t,
43 * retaining compatiblity with their fundamental <stddef.h> definitions.
47 #ifndef __STRICT_ANSI__
48 /* MSVC extends this requirement to include a definition of wchar_t,
49 * (which contravenes strict ISO-C standards conformity).
51 # define __need_wchar_t
56 /* GNU's glibc declares strcasecmp() and strncasecmp() in <string.h>,
57 * contravening POSIX.1-2008 which requires them to be declared only in
58 * <strings.h>; we may emulate this anomalous glibc behaviour, which is
59 * ostensibly to support BSD usage, (in spite of such usage now being
60 * obsolete in BSD), by simply including our <strings.h> here.
67 #define __STRING_H_SOURCED__
68 /* Prototypes for the ISO-C Standard library string functions.
70 _CRTIMP __cdecl __MINGW_NOTHROW void *memchr (const void *, int, size_t) __MINGW_ATTRIB_PURE;
71 _CRTIMP __cdecl __MINGW_NOTHROW int memcmp (const void *, const void *, size_t) __MINGW_ATTRIB_PURE;
72 _CRTIMP __cdecl __MINGW_NOTHROW void *memcpy (void *, const void *, size_t);
73 _CRTIMP __cdecl __MINGW_NOTHROW void *memmove (void *, const void *, size_t);
74 _CRTIMP __cdecl __MINGW_NOTHROW void *memset (void *, int, size_t);
75 _CRTIMP __cdecl __MINGW_NOTHROW char *strcat (char *, const char *);
76 _CRTIMP __cdecl __MINGW_NOTHROW char *strchr (const char *, int) __MINGW_ATTRIB_PURE;
77 _CRTIMP __cdecl __MINGW_NOTHROW int strcmp (const char *, const char *) __MINGW_ATTRIB_PURE;
78 _CRTIMP __cdecl __MINGW_NOTHROW int strcoll (const char *, const char *); /* Compare using locale */
79 _CRTIMP __cdecl __MINGW_NOTHROW char *strcpy (char *, const char *);
80 _CRTIMP __cdecl __MINGW_NOTHROW size_t strcspn (const char *, const char *) __MINGW_ATTRIB_PURE;
81 _CRTIMP __cdecl __MINGW_NOTHROW char *strerror (int); /* NOTE: NOT an old name wrapper. */
83 _CRTIMP __cdecl __MINGW_NOTHROW size_t strlen (const char *) __MINGW_ATTRIB_PURE;
84 _CRTIMP __cdecl __MINGW_NOTHROW char *strncat (char *, const char *, size_t);
85 _CRTIMP __cdecl __MINGW_NOTHROW int strncmp (const char *, const char *, size_t) __MINGW_ATTRIB_PURE;
86 _CRTIMP __cdecl __MINGW_NOTHROW char *strncpy (char *, const char *, size_t);
87 _CRTIMP __cdecl __MINGW_NOTHROW char *strpbrk (const char *, const char *) __MINGW_ATTRIB_PURE;
88 _CRTIMP __cdecl __MINGW_NOTHROW char *strrchr (const char *, int) __MINGW_ATTRIB_PURE;
89 _CRTIMP __cdecl __MINGW_NOTHROW size_t strspn (const char *, const char *) __MINGW_ATTRIB_PURE;
90 _CRTIMP __cdecl __MINGW_NOTHROW char *strstr (const char *, const char *) __MINGW_ATTRIB_PURE;
91 _CRTIMP __cdecl __MINGW_NOTHROW char *strtok (char *, const char *);
92 _CRTIMP __cdecl __MINGW_NOTHROW size_t strxfrm (char *, const char *, size_t);
94 #ifndef __STRICT_ANSI__
96 * Extra non-ANSI functions provided by the CRTDLL library
98 _CRTIMP __cdecl __MINGW_NOTHROW char *_strerror (const char *);
99 _CRTIMP __cdecl __MINGW_NOTHROW void *_memccpy (void *, const void *, int, size_t);
100 _CRTIMP __cdecl __MINGW_NOTHROW int _memicmp (const void *, const void *, size_t);
101 _CRTIMP __cdecl __MINGW_NOTHROW char *_strdup (const char *) __MINGW_ATTRIB_MALLOC;
102 _CRTIMP __cdecl __MINGW_NOTHROW int _strcmpi (const char *, const char *);
103 _CRTIMP __cdecl __MINGW_NOTHROW int _stricoll (const char *, const char *);
104 _CRTIMP __cdecl __MINGW_NOTHROW char *_strlwr (char *);
105 _CRTIMP __cdecl __MINGW_NOTHROW char *_strnset (char *, int, size_t);
106 _CRTIMP __cdecl __MINGW_NOTHROW char *_strrev (char *);
107 _CRTIMP __cdecl __MINGW_NOTHROW char *_strset (char *, int);
108 _CRTIMP __cdecl __MINGW_NOTHROW char *_strupr (char *);
109 _CRTIMP __cdecl __MINGW_NOTHROW void _swab (const char *, char *, size_t);
111 /* MSVC's non-ANSI _stricmp() and _strnicmp() functions must also be
112 * prototyped here, but we need to share them with <strings.h>, where
113 * we declare their POSIX strcasecmp() and strncasecmp() equivalents;
114 * get the requisite prototypes by selective <strings.h> inclusion,
115 * (noting that we've already done so, if emulating glibc).
122 /* These were not present in the CRTDLL prior to the first release of
123 * MSVCRT.DLL, but are available in all versions of that library.
125 _CRTIMP __cdecl __MINGW_NOTHROW int _strncoll(const char *, const char *, size_t);
126 _CRTIMP __cdecl __MINGW_NOTHROW int _strnicoll(const char *, const char *, size_t);
129 # ifndef _NO_OLDNAMES
130 /* Non-underscore decorated versions of non-ANSI functions. They live in the
131 * OLDNAMES libraries, whence they provide a little extra portability.
133 _CRTIMP __cdecl __MINGW_NOTHROW void *memccpy (void *, const void *, int, size_t);
134 _CRTIMP __cdecl __MINGW_NOTHROW int memicmp (const void *, const void *, size_t);
135 _CRTIMP __cdecl __MINGW_NOTHROW char *strdup (const char *) __MINGW_ATTRIB_MALLOC;
136 _CRTIMP __cdecl __MINGW_NOTHROW int strcmpi (const char *, const char *);
137 _CRTIMP __cdecl __MINGW_NOTHROW int stricmp (const char *, const char *);
138 _CRTIMP __cdecl __MINGW_NOTHROW int stricoll (const char *, const char *);
139 _CRTIMP __cdecl __MINGW_NOTHROW char *strlwr (char *);
140 _CRTIMP __cdecl __MINGW_NOTHROW int strnicmp (const char *, const char *, size_t);
141 _CRTIMP __cdecl __MINGW_NOTHROW char *strnset (char *, int, size_t);
142 _CRTIMP __cdecl __MINGW_NOTHROW char *strrev (char *);
143 _CRTIMP __cdecl __MINGW_NOTHROW char *strset (char *, int);
144 _CRTIMP __cdecl __MINGW_NOTHROW char *strupr (char *);
147 /* FIXME: Do we really care that UWin doesn't support this? We are
148 * under no obligation to support UWin.
150 _CRTIMP __cdecl __MINGW_NOTHROW void swab (const char *, char *, size_t);
152 # endif /* ! _UWIN */
153 # endif /* ! _NO_OLDNAMES */
155 /* MSVC also expects <string.h> to declare duplicates of the wchar_t
156 * string functions which are nominally declared in <wchar.h>, (which
157 * is where ISO-C specifies that they should be declared). For the
158 * convenience of applications which rely on this Microsoft anomaly,
159 * inclusion of <wchar.h>, within the current __STRING_H_SOURCED__
160 * scope, will selectively expose the required function prototypes;
161 * however, strictly ISO-C conforming applications should include
162 * <wchar.h> directly; they should not rely on this MSVC specific
163 * anomalous behaviour. (We use the quoted form of inclusion here,
164 * to ensure that we get our own "wchar.h", and not any predecessor
165 * which may have been insinuated into the system include path, and
166 * so could interfere with our mechanism for partial inclusion of
167 * shared header content).
171 #endif /* ! __STRICT_ANSI__ */
173 #if __MSVCRT_VERSION__ >= __MSVCR80_DLL
174 /* MSVCR80.DLL adds a (mostly) POSIX.1-2008 conforming strnlen(); (it's
175 * also available in MSVCRT.DLL from _WIN32_WINNT_VISTA onwards, but we
176 * pretend otherwise, since recent GCC will try to use the function when
177 * it can be found in libmsvcrt.a, so breaking it for use on WinXP and
180 _CRTIMP __cdecl __MINGW_NOTHROW char *strnlen (const char *, size_t);
182 #elif _POSIX_C_SOURCE >= 200809L
183 /* Emulation, to support recent POSIX.1; we prefer this for ALL versions
184 * of MSVCRT.DLL, (even those which already provide strnlen()); to avoid
185 * the GCC breakage noted above. (Note that we implement strnlen() with
186 * the alternative external name, __mingw_strnlen() in libmingwex.a, to
187 * avoid possible link time collision with MSVCR80.DLL's implementation,
188 * then map this to strnlen() via a __CRT_ALIAS, with stubs designated
189 * for linking from within the appropriate oldname libraries.
191 extern size_t __mingw_strnlen (const char *, size_t);
193 __JMPSTUB__(( LIB=coldname; FUNCTION=strnlen ))
194 __CRT_ALIAS size_t strnlen (const char *__text, size_t __maxlen)
195 { return __mingw_strnlen (__text, __maxlen); }
197 #endif /* _POSIX_C_SOURCE >= 200809L */
199 #undef __STRING_H_SOURCED__
203 #endif /* ! RC_INVOKED */
204 #endif /* !_STRING_H: $RCSfile$: end of file */