1 /* A GNU-like <stdio.h>.
3 Copyright (C) 2004, 2007-2024 Free Software Foundation, Inc.
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19 @PRAGMA_SYSTEM_HEADER@
23 #if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
24 /* Special invocation convention:
25 - Inside glibc header files.
26 - On OSF/1 5.1 we have a sequence of nested includes
27 <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
28 <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
29 In this situation, the functions are not yet declared, therefore we cannot
30 provide the C++ aliases. */
32 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
35 /* Normal invocation convention. */
37 #ifndef _@GUARD_PREFIX@_STDIO_H
39 /* Suppress macOS deprecation warnings for sprintf and vsprintf. */
40 #if (defined __APPLE__ && defined __MACH__) && !defined _POSIX_C_SOURCE
41 # ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
42 # include <AvailabilityMacros.h>
44 # if (defined MAC_OS_X_VERSION_MIN_REQUIRED \
45 && 130000 <= MAC_OS_X_VERSION_MIN_REQUIRED)
46 # define _POSIX_C_SOURCE 200809L
47 # define _GL_DEFINED__POSIX_C_SOURCE
51 #define _GL_ALREADY_INCLUDING_STDIO_H
53 /* The include_next requires a split double-inclusion guard. */
54 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
56 #undef _GL_ALREADY_INCLUDING_STDIO_H
58 #ifdef _GL_DEFINED__POSIX_C_SOURCE
59 # undef _GL_DEFINED__POSIX_C_SOURCE
60 # undef _POSIX_C_SOURCE
63 #ifndef _@GUARD_PREFIX@_STDIO_H
64 #define _@GUARD_PREFIX@_STDIO_H
66 /* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT,
67 _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK,
69 #if !_GL_CONFIG_H_INCLUDED
70 #error "Please include config.h first."
73 /* Get va_list. Needed on many systems, including glibc 2.8. */
78 /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8
80 May also define off_t to a 64-bit type on native Windows.
81 Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */
82 #include <sys/types.h>
84 /* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */
85 /* But in any case avoid namespace pollution on glibc systems. */
86 #if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \
87 && ! defined __GLIBC__
91 /* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>. */
92 /* But in any case avoid namespace pollution on glibc systems. */
93 #if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
94 && ! defined __GLIBC__
95 # include <sys/stat.h>
98 /* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>. We must include
99 it before we #define perror rpl_perror. */
100 /* But in any case avoid namespace pollution on glibc systems. */
101 #if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \
102 && (defined _WIN32 && ! defined __CYGWIN__) \
103 && ! defined __GLIBC__
107 /* MSVC declares 'remove' in <io.h>, not in <stdio.h>. We must include
108 it before we #define remove rpl_remove. */
109 /* MSVC declares 'rename' in <io.h>, not in <stdio.h>. We must include
110 it before we #define rename rpl_rename. */
111 /* But in any case avoid namespace pollution on glibc systems. */
112 #if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \
113 && (defined _WIN32 && ! defined __CYGWIN__) \
114 && ! defined __GLIBC__
119 /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
120 that can be freed by passing them as the Ith argument to the
122 #ifndef _GL_ATTRIBUTE_DEALLOC
124 # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
126 # define _GL_ATTRIBUTE_DEALLOC(f, i)
130 /* The __attribute__ feature is available in gcc versions 2.5 and later.
131 The __-protected variants of the attributes 'format' and 'printf' are
132 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
133 We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
134 gnulib and libintl do '#define printf __printf__' when they override
135 the 'printf' function. */
136 #ifndef _GL_ATTRIBUTE_FORMAT
137 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || defined __clang__
138 # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
140 # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
144 /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
146 #ifndef _GL_ATTRIBUTE_MALLOC
147 # if __GNUC__ >= 3 || defined __clang__
148 # define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
150 # define _GL_ATTRIBUTE_MALLOC
154 /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
156 #ifndef _GL_ATTRIBUTE_NOTHROW
157 # if defined __cplusplus
158 # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4
159 # if __cplusplus >= 201103L
160 # define _GL_ATTRIBUTE_NOTHROW noexcept (true)
162 # define _GL_ATTRIBUTE_NOTHROW throw ()
165 # define _GL_ATTRIBUTE_NOTHROW
168 # if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
169 # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
171 # define _GL_ATTRIBUTE_NOTHROW
176 /* An __attribute__ __format__ specifier for a function that takes a format
177 string and arguments, where the format string directives are the ones
178 standardized by ISO C99 and POSIX.
179 _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */
180 /* __gnu_printf__ is supported in GCC >= 4.4. */
181 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
182 # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__
184 # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__
187 /* An __attribute__ __format__ specifier for a function that takes a format
188 string and arguments, where the format string directives are the ones of the
189 system printf(), rather than the ones standardized by ISO C99 and POSIX.
190 _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM */
191 /* On mingw, Gnulib sets __USE_MINGW_ANSI_STDIO in order to get closer to
192 the standards. The macro GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU indicates
193 whether this change is effective. On older mingw, it is not. */
194 #if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
195 # define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD
197 # define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM __printf__
200 /* _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD
201 indicates to GCC that the function takes a format string and arguments,
202 where the format string directives are the ones standardized by ISO C99
204 #define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(formatstring_parameter, first_argument) \
205 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, formatstring_parameter, first_argument))
207 /* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD,
208 except that it indicates to GCC that the supported format string directives
209 are the ones of the system printf(), rather than the ones standardized by
210 ISO C99 and POSIX. */
211 #define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
212 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, formatstring_parameter, first_argument))
214 /* _GL_ATTRIBUTE_FORMAT_SCANF
215 indicates to GCC that the function takes a format string and arguments,
216 where the format string directives are the ones standardized by ISO C99
218 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
219 # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
220 _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument))
222 # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
223 _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
226 /* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF,
227 except that it indicates to GCC that the supported format string directives
228 are the ones of the system scanf(), rather than the ones standardized by
229 ISO C99 and POSIX. */
230 #define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
231 _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
233 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
235 /* The definition of _GL_ARG_NONNULL is copied here. */
237 /* The definition of _GL_WARN_ON_USE is copied here. */
239 /* Macros for stringification. */
240 #define _GL_STDIO_STRINGIZE(token) #token
241 #define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
243 /* When also using extern inline, suppress the use of static inline in
244 standard headers of problematic Apple configurations, as Libc at
245 least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
246 <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>.
247 Perhaps Apple will fix this some day. */
248 #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
249 && defined __GNUC__ && defined __STDC__)
250 # undef putc_unlocked
254 /* Maximum number of characters produced by printing a NaN value. */
255 #ifndef _PRINTF_NAN_LEN_MAX
256 # if defined __FreeBSD__ || defined __DragonFly__ \
257 || defined __NetBSD__ \
258 || (defined __APPLE__ && defined __MACH__)
259 /* On BSD systems, a NaN value prints as just "nan", without a sign. */
260 # define _PRINTF_NAN_LEN_MAX 3
261 # elif (__GLIBC__ >= 2) || MUSL_LIBC || defined __OpenBSD__ || defined __sun || defined __CYGWIN__
262 /* glibc, musl libc, OpenBSD, Solaris libc, and Cygwin produce "[-]nan". */
263 # define _PRINTF_NAN_LEN_MAX 4
265 /* AIX produces "[-]NaNQ". */
266 # define _PRINTF_NAN_LEN_MAX 5
267 # elif defined _WIN32 && !defined __CYGWIN__
268 /* On native Windows, the output can be:
269 - with MSVC ucrt: "[-]nan" or "[-]nan(ind)" or "[-]nan(snan)",
270 - with mingw: "[-]1.#IND" or "[-]1.#QNAN". */
271 # define _PRINTF_NAN_LEN_MAX 10
273 /* On IRIX, the output typically is "[-]nan0xNNNNNNNN" with 8 hexadecimal
275 # define _PRINTF_NAN_LEN_MAX 14
277 /* We don't know, but 32 should be a safe maximum. */
278 # define _PRINTF_NAN_LEN_MAX 32
284 # if @REPLACE_DPRINTF@
285 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
286 # define dprintf rpl_dprintf
288 _GL_FUNCDECL_RPL (dprintf
, int, (int fd
, const char *restrict format
, ...)
289 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
290 _GL_ARG_NONNULL ((2)));
291 _GL_CXXALIAS_RPL (dprintf
, int, (int fd
, const char *restrict format
, ...));
294 _GL_FUNCDECL_SYS (dprintf
, int, (int fd
, const char *restrict format
, ...)
295 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
296 _GL_ARG_NONNULL ((2)));
298 _GL_CXXALIAS_SYS (dprintf
, int, (int fd
, const char *restrict format
, ...));
301 _GL_CXXALIASWARN (dprintf
);
303 #elif defined GNULIB_POSIXCHECK
305 # if HAVE_RAW_DECL_DPRINTF
306 _GL_WARN_ON_USE (dprintf
, "dprintf is unportable - "
307 "use gnulib module dprintf for portability");
312 /* Close STREAM and its underlying file descriptor. */
313 # if @REPLACE_FCLOSE@
314 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
315 # define fclose rpl_fclose
317 _GL_FUNCDECL_RPL (fclose
, int, (FILE *stream
) _GL_ARG_NONNULL ((1)));
318 _GL_CXXALIAS_RPL (fclose
, int, (FILE *stream
));
320 _GL_CXXALIAS_SYS (fclose
, int, (FILE *stream
));
323 _GL_CXXALIASWARN (fclose
);
325 #elif defined GNULIB_POSIXCHECK
327 /* Assume fclose is always declared. */
328 _GL_WARN_ON_USE (fclose
, "fclose is not always POSIX compliant - "
329 "use gnulib module fclose for portable POSIX compliance");
332 #if @GNULIB_MDA_FCLOSEALL@
333 /* On native Windows, map 'fcloseall' to '_fcloseall', so that -loldnames is
334 not required. In C++ with GNULIB_NAMESPACE, avoid differences between
335 platforms by defining GNULIB_NAMESPACE::fcloseall on all platforms that have
337 # if defined _WIN32 && !defined __CYGWIN__
338 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
340 # define fcloseall _fcloseall
342 _GL_CXXALIAS_MDA (fcloseall
, int, (void));
344 # if @HAVE_DECL_FCLOSEALL@
345 # if defined __FreeBSD__ || defined __DragonFly__
346 _GL_CXXALIAS_SYS (fcloseall
, void, (void));
348 _GL_CXXALIAS_SYS (fcloseall
, int, (void));
352 # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_FCLOSEALL@
353 _GL_CXXALIASWARN (fcloseall
);
358 # if @REPLACE_FDOPEN@
359 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
361 # define fdopen rpl_fdopen
363 _GL_FUNCDECL_RPL (fdopen
, FILE *,
364 (int fd
, const char *mode
)
365 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose
, 1)
366 _GL_ATTRIBUTE_MALLOC
);
367 _GL_CXXALIAS_RPL (fdopen
, FILE *, (int fd
, const char *mode
));
368 # elif defined _WIN32 && !defined __CYGWIN__
369 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
371 # define fdopen _fdopen
373 _GL_CXXALIAS_MDA (fdopen
, FILE *, (int fd
, const char *mode
));
376 /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
377 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
378 _GL_FUNCDECL_SYS (fdopen
, FILE *,
379 (int fd
, const char *mode
)
380 _GL_ATTRIBUTE_NOTHROW
381 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose
, 1)
382 _GL_ATTRIBUTE_MALLOC
);
384 _GL_FUNCDECL_SYS (fdopen
, FILE *,
385 (int fd
, const char *mode
)
386 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose
, 1)
387 _GL_ATTRIBUTE_MALLOC
);
390 _GL_CXXALIAS_SYS (fdopen
, FILE *, (int fd
, const char *mode
));
392 _GL_CXXALIASWARN (fdopen
);
394 # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen
395 /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
396 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
397 _GL_FUNCDECL_SYS (fdopen
, FILE *,
398 (int fd
, const char *mode
)
399 _GL_ATTRIBUTE_NOTHROW
400 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose
, 1)
401 _GL_ATTRIBUTE_MALLOC
);
403 _GL_FUNCDECL_SYS (fdopen
, FILE *,
404 (int fd
, const char *mode
)
405 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose
, 1)
406 _GL_ATTRIBUTE_MALLOC
);
409 # if defined GNULIB_POSIXCHECK
411 /* Assume fdopen is always declared. */
412 _GL_WARN_ON_USE (fdopen
, "fdopen on native Windows platforms is not POSIX compliant - "
413 "use gnulib module fdopen for portability");
414 # elif @GNULIB_MDA_FDOPEN@
415 /* On native Windows, map 'fdopen' to '_fdopen', so that -loldnames is not
416 required. In C++ with GNULIB_NAMESPACE, avoid differences between
417 platforms by defining GNULIB_NAMESPACE::fdopen always. */
418 # if defined _WIN32 && !defined __CYGWIN__
419 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
421 # define fdopen _fdopen
423 _GL_CXXALIAS_MDA (fdopen
, FILE *, (int fd
, const char *mode
));
425 _GL_CXXALIAS_SYS (fdopen
, FILE *, (int fd
, const char *mode
));
427 _GL_CXXALIASWARN (fdopen
);
432 /* Flush all pending data on STREAM according to POSIX rules. Both
433 output and seekable input streams are supported.
434 Note! LOSS OF DATA can occur if fflush is applied on an input stream
435 that is _not_seekable_ or on an update stream that is _not_seekable_
436 and in which the most recent operation was input. Seekability can
437 be tested with lseek(fileno(fp),0,SEEK_CUR). */
438 # if @REPLACE_FFLUSH@
439 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
440 # define fflush rpl_fflush
442 _GL_FUNCDECL_RPL (fflush
, int, (FILE *gl_stream
));
443 _GL_CXXALIAS_RPL (fflush
, int, (FILE *gl_stream
));
445 _GL_CXXALIAS_SYS (fflush
, int, (FILE *gl_stream
));
448 _GL_CXXALIASWARN (fflush
);
450 #elif defined GNULIB_POSIXCHECK
452 /* Assume fflush is always declared. */
453 _GL_WARN_ON_USE (fflush
, "fflush is not always POSIX compliant - "
454 "use gnulib module fflush for portable POSIX compliance");
458 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
459 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
461 # define fgetc rpl_fgetc
463 _GL_FUNCDECL_RPL (fgetc
, int, (FILE *stream
) _GL_ARG_NONNULL ((1)));
464 _GL_CXXALIAS_RPL (fgetc
, int, (FILE *stream
));
466 _GL_CXXALIAS_SYS (fgetc
, int, (FILE *stream
));
469 _GL_CXXALIASWARN (fgetc
);
474 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
475 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
477 # define fgets rpl_fgets
479 _GL_FUNCDECL_RPL (fgets
, char *,
480 (char *restrict s
, int n
, FILE *restrict stream
)
481 _GL_ARG_NONNULL ((1, 3)));
482 _GL_CXXALIAS_RPL (fgets
, char *,
483 (char *restrict s
, int n
, FILE *restrict stream
));
485 _GL_CXXALIAS_SYS (fgets
, char *,
486 (char *restrict s
, int n
, FILE *restrict stream
));
489 _GL_CXXALIASWARN (fgets
);
493 #if @GNULIB_MDA_FILENO@
494 /* On native Windows, map 'fileno' to '_fileno', so that -loldnames is not
495 required. In C++ with GNULIB_NAMESPACE, avoid differences between
496 platforms by defining GNULIB_NAMESPACE::fileno always. */
497 # if defined _WIN32 && !defined __CYGWIN__
498 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
500 # define fileno _fileno
502 _GL_CXXALIAS_MDA (fileno
, int, (FILE *restrict stream
));
504 _GL_CXXALIAS_SYS (fileno
, int, (FILE *restrict stream
));
506 _GL_CXXALIASWARN (fileno
);
510 # if (@GNULIB_FOPEN@ && @REPLACE_FOPEN@) \
511 || (@GNULIB_FOPEN_GNU@ && @REPLACE_FOPEN_FOR_FOPEN_GNU@)
512 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
514 # define fopen rpl_fopen
516 _GL_FUNCDECL_RPL (fopen
, FILE *,
517 (const char *restrict filename
, const char *restrict mode
)
518 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose
, 1)
519 _GL_ATTRIBUTE_MALLOC
);
520 _GL_CXXALIAS_RPL (fopen
, FILE *,
521 (const char *restrict filename
, const char *restrict mode
));
524 /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
525 _GL_FUNCDECL_SYS (fopen
, FILE *,
526 (const char *restrict filename
, const char *restrict mode
)
527 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose
, 1));
529 _GL_CXXALIAS_SYS (fopen
, FILE *,
530 (const char *restrict filename
, const char *restrict mode
));
533 _GL_CXXALIASWARN (fopen
);
536 # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fopen
537 /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
538 _GL_FUNCDECL_SYS (fopen
, FILE *,
539 (const char *restrict filename
, const char *restrict mode
)
540 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose
, 1));
542 # if defined GNULIB_POSIXCHECK
544 /* Assume fopen is always declared. */
545 _GL_WARN_ON_USE (fopen
, "fopen on native Windows platforms is not POSIX compliant - "
546 "use gnulib module fopen for portability");
550 #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
551 # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
552 || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
553 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
554 # define fprintf rpl_fprintf
556 # define GNULIB_overrides_fprintf 1
557 # if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
558 _GL_FUNCDECL_RPL (fprintf
, int,
559 (FILE *restrict fp
, const char *restrict format
, ...)
560 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
561 _GL_ARG_NONNULL ((1, 2)));
563 _GL_FUNCDECL_RPL (fprintf
, int,
564 (FILE *restrict fp
, const char *restrict format
, ...)
565 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
566 _GL_ARG_NONNULL ((1, 2)));
568 _GL_CXXALIAS_RPL (fprintf
, int,
569 (FILE *restrict fp
, const char *restrict format
, ...));
571 _GL_CXXALIAS_SYS (fprintf
, int,
572 (FILE *restrict fp
, const char *restrict format
, ...));
575 _GL_CXXALIASWARN (fprintf
);
578 #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
579 # if !GNULIB_overrides_fprintf
582 /* Assume fprintf is always declared. */
583 _GL_WARN_ON_USE (fprintf
, "fprintf is not always POSIX compliant - "
584 "use gnulib module fprintf-posix for portable "
589 /* Discard all pending buffered I/O data on STREAM.
590 STREAM must not be wide-character oriented.
591 When discarding pending output, the file position is set back to where it
592 was before the write calls. When discarding pending input, the file
593 position is advanced to match the end of the previously read input.
594 Return 0 if successful. Upon error, return -1 and set errno. */
595 # if @REPLACE_FPURGE@
596 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
597 # define fpurge rpl_fpurge
599 _GL_FUNCDECL_RPL (fpurge
, int, (FILE *gl_stream
) _GL_ARG_NONNULL ((1)));
600 _GL_CXXALIAS_RPL (fpurge
, int, (FILE *gl_stream
));
602 # if !@HAVE_DECL_FPURGE@
603 _GL_FUNCDECL_SYS (fpurge
, int, (FILE *gl_stream
) _GL_ARG_NONNULL ((1)));
605 _GL_CXXALIAS_SYS (fpurge
, int, (FILE *gl_stream
));
607 _GL_CXXALIASWARN (fpurge
);
608 #elif defined GNULIB_POSIXCHECK
610 # if HAVE_RAW_DECL_FPURGE
611 _GL_WARN_ON_USE (fpurge
, "fpurge is not always present - "
612 "use gnulib module fpurge for portability");
617 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
618 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
620 # define fputc rpl_fputc
622 _GL_FUNCDECL_RPL (fputc
, int, (int c
, FILE *stream
) _GL_ARG_NONNULL ((2)));
623 _GL_CXXALIAS_RPL (fputc
, int, (int c
, FILE *stream
));
625 _GL_CXXALIAS_SYS (fputc
, int, (int c
, FILE *stream
));
628 _GL_CXXALIASWARN (fputc
);
633 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
634 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
636 # define fputs rpl_fputs
638 _GL_FUNCDECL_RPL (fputs
, int,
639 (const char *restrict string
, FILE *restrict stream
)
640 _GL_ARG_NONNULL ((1, 2)));
641 _GL_CXXALIAS_RPL (fputs
, int,
642 (const char *restrict string
, FILE *restrict stream
));
644 _GL_CXXALIAS_SYS (fputs
, int,
645 (const char *restrict string
, FILE *restrict stream
));
648 _GL_CXXALIASWARN (fputs
);
653 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
654 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
656 # define fread rpl_fread
658 _GL_FUNCDECL_RPL (fread
, size_t,
659 (void *restrict ptr
, size_t s
, size_t n
,
660 FILE *restrict stream
)
661 _GL_ARG_NONNULL ((4)));
662 _GL_CXXALIAS_RPL (fread
, size_t,
663 (void *restrict ptr
, size_t s
, size_t n
,
664 FILE *restrict stream
));
666 _GL_CXXALIAS_SYS (fread
, size_t,
667 (void *restrict ptr
, size_t s
, size_t n
,
668 FILE *restrict stream
));
671 _GL_CXXALIASWARN (fread
);
676 # if @REPLACE_FREOPEN@
677 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
679 # define freopen rpl_freopen
681 _GL_FUNCDECL_RPL (freopen
, FILE *,
682 (const char *restrict filename
, const char *restrict mode
,
683 FILE *restrict stream
)
684 _GL_ARG_NONNULL ((2, 3)));
685 _GL_CXXALIAS_RPL (freopen
, FILE *,
686 (const char *restrict filename
, const char *restrict mode
,
687 FILE *restrict stream
));
689 _GL_CXXALIAS_SYS (freopen
, FILE *,
690 (const char *restrict filename
, const char *restrict mode
,
691 FILE *restrict stream
));
694 _GL_CXXALIASWARN (freopen
);
696 #elif defined GNULIB_POSIXCHECK
698 /* Assume freopen is always declared. */
699 _GL_WARN_ON_USE (freopen
,
700 "freopen on native Windows platforms is not POSIX compliant - "
701 "use gnulib module freopen for portability");
705 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
706 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
708 # define fscanf rpl_fscanf
710 _GL_FUNCDECL_RPL (fscanf
, int,
711 (FILE *restrict stream
, const char *restrict format
, ...)
712 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
713 _GL_ARG_NONNULL ((1, 2)));
714 _GL_CXXALIAS_RPL (fscanf
, int,
715 (FILE *restrict stream
, const char *restrict format
, ...));
717 _GL_CXXALIAS_SYS (fscanf
, int,
718 (FILE *restrict stream
, const char *restrict format
, ...));
721 _GL_CXXALIASWARN (fscanf
);
726 /* Set up the following warnings, based on which modules are in use.
727 GNU Coding Standards discourage the use of fseek, since it imposes
728 an arbitrary limitation on some 32-bit hosts. Remember that the
729 fseek module depends on the fseeko module, so we only have three
732 1. The developer is not using either module. Issue a warning under
733 GNULIB_POSIXCHECK for both functions, to remind them that both
734 functions have bugs on some systems. _GL_NO_LARGE_FILES has no
735 impact on this warning.
737 2. The developer is using both modules. They may be unaware of the
738 arbitrary limitations of fseek, so issue a warning under
739 GNULIB_POSIXCHECK. On the other hand, they may be using both
740 modules intentionally, so the developer can define
741 _GL_NO_LARGE_FILES in the compilation units where the use of fseek
742 is safe, to silence the warning.
744 3. The developer is using the fseeko module, but not fseek. Gnulib
745 guarantees that fseek will still work around platform bugs in that
746 case, but we presume that the developer is aware of the pitfalls of
747 fseek and was trying to avoid it, so issue a warning even when
748 GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be
749 defined to silence the warning in particular compilation units.
750 In C++ compilations with GNULIB_NAMESPACE, in order to avoid that
751 fseek gets defined as a macro, it is recommended that the developer
752 uses the fseek module, even if he is not calling the fseek function.
754 Most gnulib clients that perform stream operations should fall into
758 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
759 # define _GL_FSEEK_WARN /* Category 2, above. */
763 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
765 # define fseek rpl_fseek
767 _GL_FUNCDECL_RPL (fseek
, int, (FILE *fp
, long offset
, int whence
)
768 _GL_ARG_NONNULL ((1)));
769 _GL_CXXALIAS_RPL (fseek
, int, (FILE *fp
, long offset
, int whence
));
771 _GL_CXXALIAS_SYS (fseek
, int, (FILE *fp
, long offset
, int whence
));
774 _GL_CXXALIASWARN (fseek
);
779 # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
780 # define _GL_FSEEK_WARN /* Category 3, above. */
783 # if @REPLACE_FSEEKO@
784 /* Provide an fseeko function that is aware of a preceding fflush(), and which
786 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
788 # define fseeko rpl_fseeko
790 _GL_FUNCDECL_RPL (fseeko
, int, (FILE *fp
, off_t offset
, int whence
)
791 _GL_ARG_NONNULL ((1)));
792 _GL_CXXALIAS_RPL (fseeko
, int, (FILE *fp
, off_t offset
, int whence
));
794 # if ! @HAVE_DECL_FSEEKO@
795 _GL_FUNCDECL_SYS (fseeko
, int, (FILE *fp
, off_t offset
, int whence
)
796 _GL_ARG_NONNULL ((1)));
798 _GL_CXXALIAS_SYS (fseeko
, int, (FILE *fp
, off_t offset
, int whence
));
800 _GL_CXXALIASWARN (fseeko
);
801 #elif defined GNULIB_POSIXCHECK
802 # define _GL_FSEEK_WARN /* Category 1, above. */
805 # if HAVE_RAW_DECL_FSEEKO
806 _GL_WARN_ON_USE (fseeko
, "fseeko is unportable - "
807 "use gnulib module fseeko for portability");
811 #ifdef _GL_FSEEK_WARN
812 # undef _GL_FSEEK_WARN
813 /* Here, either fseek is undefined (but C89 guarantees that it is
814 declared), or it is defined as rpl_fseek (declared above). */
815 _GL_WARN_ON_USE (fseek
, "fseek cannot handle files larger than 4 GB "
816 "on 32-bit platforms - "
817 "use fseeko function for handling of large files");
821 /* ftell, ftello. See the comments on fseek/fseeko. */
824 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
825 # define _GL_FTELL_WARN /* Category 2, above. */
829 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
831 # define ftell rpl_ftell
833 _GL_FUNCDECL_RPL (ftell
, long, (FILE *fp
) _GL_ARG_NONNULL ((1)));
834 _GL_CXXALIAS_RPL (ftell
, long, (FILE *fp
));
836 _GL_CXXALIAS_SYS (ftell
, long, (FILE *fp
));
839 _GL_CXXALIASWARN (ftell
);
844 # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
845 # define _GL_FTELL_WARN /* Category 3, above. */
848 # if @REPLACE_FTELLO@
849 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
851 # define ftello rpl_ftello
853 _GL_FUNCDECL_RPL (ftello
, off_t
, (FILE *fp
) _GL_ARG_NONNULL ((1)));
854 _GL_CXXALIAS_RPL (ftello
, off_t
, (FILE *fp
));
856 # if ! @HAVE_DECL_FTELLO@
857 _GL_FUNCDECL_SYS (ftello
, off_t
, (FILE *fp
) _GL_ARG_NONNULL ((1)));
859 _GL_CXXALIAS_SYS (ftello
, off_t
, (FILE *fp
));
861 _GL_CXXALIASWARN (ftello
);
862 #elif defined GNULIB_POSIXCHECK
863 # define _GL_FTELL_WARN /* Category 1, above. */
866 # if HAVE_RAW_DECL_FTELLO
867 _GL_WARN_ON_USE (ftello
, "ftello is unportable - "
868 "use gnulib module ftello for portability");
872 #ifdef _GL_FTELL_WARN
873 # undef _GL_FTELL_WARN
874 /* Here, either ftell is undefined (but C89 guarantees that it is
875 declared), or it is defined as rpl_ftell (declared above). */
876 _GL_WARN_ON_USE (ftell
, "ftell cannot handle files larger than 4 GB "
877 "on 32-bit platforms - "
878 "use ftello function for handling of large files");
883 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
884 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
886 # define fwrite rpl_fwrite
888 _GL_FUNCDECL_RPL (fwrite
, size_t,
889 (const void *restrict ptr
, size_t s
, size_t n
,
890 FILE *restrict stream
)
891 _GL_ARG_NONNULL ((1, 4)));
892 _GL_CXXALIAS_RPL (fwrite
, size_t,
893 (const void *restrict ptr
, size_t s
, size_t n
,
894 FILE *restrict stream
));
896 _GL_CXXALIAS_SYS (fwrite
, size_t,
897 (const void *restrict ptr
, size_t s
, size_t n
,
898 FILE *restrict stream
));
900 /* Work around bug 11959 when fortifying glibc 2.4 through 2.15
901 <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>,
902 which sometimes causes an unwanted diagnostic for fwrite calls.
903 This affects only function declaration attributes under certain
904 versions of gcc and clang, and is not needed for C++. */
905 # if (0 < __USE_FORTIFY_LEVEL \
906 && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
907 && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \
908 && !defined __cplusplus)
910 # undef fwrite_unlocked
911 _GL_EXTERN_C
size_t __REDIRECT (rpl_fwrite
,
912 (const void *__restrict
, size_t, size_t,
915 _GL_EXTERN_C
size_t __REDIRECT (rpl_fwrite_unlocked
,
916 (const void *__restrict
, size_t, size_t,
919 # define fwrite rpl_fwrite
920 # define fwrite_unlocked rpl_fwrite_unlocked
924 _GL_CXXALIASWARN (fwrite
);
929 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
930 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
932 # define getc rpl_fgetc
934 _GL_FUNCDECL_RPL (fgetc
, int, (FILE *stream
) _GL_ARG_NONNULL ((1)));
935 _GL_CXXALIAS_RPL_1 (getc
, rpl_fgetc
, int, (FILE *stream
));
937 _GL_CXXALIAS_SYS (getc
, int, (FILE *stream
));
940 _GL_CXXALIASWARN (getc
);
945 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
946 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
948 # define getchar rpl_getchar
950 _GL_FUNCDECL_RPL (getchar
, int, (void));
951 _GL_CXXALIAS_RPL (getchar
, int, (void));
953 _GL_CXXALIAS_SYS (getchar
, int, (void));
956 _GL_CXXALIASWARN (getchar
);
960 #if @GNULIB_GETDELIM@
961 /* Read input, up to (and including) the next occurrence of DELIMITER, from
962 STREAM, store it in *LINEPTR (and NUL-terminate it).
963 *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
964 bytes of space. It is realloc'd as necessary.
965 Return the number of bytes read and stored at *LINEPTR (not including the
966 NUL terminator), or -1 on error or EOF. */
967 # if @REPLACE_GETDELIM@
968 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
970 # define getdelim rpl_getdelim
972 _GL_FUNCDECL_RPL (getdelim
, ssize_t
,
973 (char **restrict lineptr
, size_t *restrict linesize
,
975 FILE *restrict stream
)
976 _GL_ARG_NONNULL ((1, 2, 4)));
977 _GL_CXXALIAS_RPL (getdelim
, ssize_t
,
978 (char **restrict lineptr
, size_t *restrict linesize
,
980 FILE *restrict stream
));
982 # if !@HAVE_DECL_GETDELIM@
983 _GL_FUNCDECL_SYS (getdelim
, ssize_t
,
984 (char **restrict lineptr
, size_t *restrict linesize
,
986 FILE *restrict stream
)
987 _GL_ARG_NONNULL ((1, 2, 4)));
989 _GL_CXXALIAS_SYS (getdelim
, ssize_t
,
990 (char **restrict lineptr
, size_t *restrict linesize
,
992 FILE *restrict stream
));
995 _GL_CXXALIASWARN (getdelim
);
997 #elif defined GNULIB_POSIXCHECK
999 # if HAVE_RAW_DECL_GETDELIM
1000 _GL_WARN_ON_USE (getdelim
, "getdelim is unportable - "
1001 "use gnulib module getdelim for portability");
1005 #if @GNULIB_GETLINE@
1006 /* Read a line, up to (and including) the next newline, from STREAM, store it
1007 in *LINEPTR (and NUL-terminate it).
1008 *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
1009 bytes of space. It is realloc'd as necessary.
1010 Return the number of bytes read and stored at *LINEPTR (not including the
1011 NUL terminator), or -1 on error or EOF. */
1012 # if @REPLACE_GETLINE@
1013 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1015 # define getline rpl_getline
1017 _GL_FUNCDECL_RPL (getline
, ssize_t
,
1018 (char **restrict lineptr
, size_t *restrict linesize
,
1019 FILE *restrict stream
)
1020 _GL_ARG_NONNULL ((1, 2, 3)));
1021 _GL_CXXALIAS_RPL (getline
, ssize_t
,
1022 (char **restrict lineptr
, size_t *restrict linesize
,
1023 FILE *restrict stream
));
1025 # if !@HAVE_DECL_GETLINE@
1026 _GL_FUNCDECL_SYS (getline
, ssize_t
,
1027 (char **restrict lineptr
, size_t *restrict linesize
,
1028 FILE *restrict stream
)
1029 _GL_ARG_NONNULL ((1, 2, 3)));
1031 _GL_CXXALIAS_SYS (getline
, ssize_t
,
1032 (char **restrict lineptr
, size_t *restrict linesize
,
1033 FILE *restrict stream
));
1035 # if __GLIBC__ >= 2 && @HAVE_DECL_GETLINE@
1036 _GL_CXXALIASWARN (getline
);
1038 #elif defined GNULIB_POSIXCHECK
1040 # if HAVE_RAW_DECL_GETLINE
1041 _GL_WARN_ON_USE (getline
, "getline is unportable - "
1042 "use gnulib module getline for portability");
1046 /* It is very rare that the developer ever has full control of stdin,
1047 so any use of gets warrants an unconditional warning; besides, C11
1050 #if HAVE_RAW_DECL_GETS && !defined __cplusplus
1051 _GL_WARN_ON_USE (gets
, "gets is a security hole - use fgets instead");
1054 #if @GNULIB_MDA_GETW@
1055 /* On native Windows, map 'getw' to '_getw', so that -loldnames is not
1056 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1057 platforms by defining GNULIB_NAMESPACE::getw always. */
1058 # if defined _WIN32 && !defined __CYGWIN__
1059 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1063 _GL_CXXALIAS_MDA (getw
, int, (FILE *restrict stream
));
1065 # if @HAVE_DECL_GETW@
1066 # if defined __APPLE__ && defined __MACH__
1067 /* The presence of the declaration depends on _POSIX_C_SOURCE. */
1068 _GL_FUNCDECL_SYS (getw
, int, (FILE *restrict stream
));
1070 _GL_CXXALIAS_SYS (getw
, int, (FILE *restrict stream
));
1074 _GL_CXXALIASWARN (getw
);
1078 #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
1080 /* Grow an obstack with formatted output. Return the number of
1081 bytes added to OBS. No trailing nul byte is added, and the
1082 object should be closed with obstack_finish before use. Upon
1083 memory allocation error, call obstack_alloc_failed_handler. Upon
1084 other error, return -1. */
1085 # if @REPLACE_OBSTACK_PRINTF@
1086 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1087 # define obstack_printf rpl_obstack_printf
1089 _GL_FUNCDECL_RPL (obstack_printf
, int,
1090 (struct obstack
*obs
, const char *format
, ...)
1091 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1092 _GL_ARG_NONNULL ((1, 2)));
1093 _GL_CXXALIAS_RPL (obstack_printf
, int,
1094 (struct obstack
*obs
, const char *format
, ...));
1096 # if !@HAVE_DECL_OBSTACK_PRINTF@
1097 _GL_FUNCDECL_SYS (obstack_printf
, int,
1098 (struct obstack
*obs
, const char *format
, ...)
1099 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1100 _GL_ARG_NONNULL ((1, 2)));
1102 _GL_CXXALIAS_SYS (obstack_printf
, int,
1103 (struct obstack
*obs
, const char *format
, ...));
1105 _GL_CXXALIASWARN (obstack_printf
);
1106 # if @REPLACE_OBSTACK_PRINTF@
1107 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1108 # define obstack_vprintf rpl_obstack_vprintf
1110 _GL_FUNCDECL_RPL (obstack_vprintf
, int,
1111 (struct obstack
*obs
, const char *format
, va_list args
)
1112 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1113 _GL_ARG_NONNULL ((1, 2)));
1114 _GL_CXXALIAS_RPL (obstack_vprintf
, int,
1115 (struct obstack
*obs
, const char *format
, va_list args
));
1117 # if !@HAVE_DECL_OBSTACK_PRINTF@
1118 _GL_FUNCDECL_SYS (obstack_vprintf
, int,
1119 (struct obstack
*obs
, const char *format
, va_list args
)
1120 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1121 _GL_ARG_NONNULL ((1, 2)));
1123 _GL_CXXALIAS_SYS (obstack_vprintf
, int,
1124 (struct obstack
*obs
, const char *format
, va_list args
));
1126 _GL_CXXALIASWARN (obstack_vprintf
);
1131 _GL_FUNCDECL_SYS (pclose
, int, (FILE *stream
) _GL_ARG_NONNULL ((1)));
1133 _GL_CXXALIAS_SYS (pclose
, int, (FILE *stream
));
1134 _GL_CXXALIASWARN (pclose
);
1135 #elif defined GNULIB_POSIXCHECK
1137 # if HAVE_RAW_DECL_PCLOSE
1138 _GL_WARN_ON_USE (pclose
, "pclose is unportable - "
1139 "use gnulib module pclose for more portability");
1144 /* Print a message to standard error, describing the value of ERRNO,
1145 (if STRING is not NULL and not empty) prefixed with STRING and ": ",
1146 and terminated with a newline. */
1147 # if @REPLACE_PERROR@
1148 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1149 # define perror rpl_perror
1151 _GL_FUNCDECL_RPL (perror
, void, (const char *string
));
1152 _GL_CXXALIAS_RPL (perror
, void, (const char *string
));
1154 _GL_CXXALIAS_SYS (perror
, void, (const char *string
));
1157 _GL_CXXALIASWARN (perror
);
1159 #elif defined GNULIB_POSIXCHECK
1161 /* Assume perror is always declared. */
1162 _GL_WARN_ON_USE (perror
, "perror is not always POSIX compliant - "
1163 "use gnulib module perror for portability");
1167 # if @REPLACE_POPEN@
1168 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1170 # define popen rpl_popen
1172 _GL_FUNCDECL_RPL (popen
, FILE *,
1173 (const char *cmd
, const char *mode
)
1174 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose
, 1)
1175 _GL_ATTRIBUTE_MALLOC
);
1176 _GL_CXXALIAS_RPL (popen
, FILE *, (const char *cmd
, const char *mode
));
1178 # if !@HAVE_POPEN@ || __GNUC__ >= 11
1179 _GL_FUNCDECL_SYS (popen
, FILE *,
1180 (const char *cmd
, const char *mode
)
1181 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose
, 1)
1182 _GL_ATTRIBUTE_MALLOC
);
1184 _GL_CXXALIAS_SYS (popen
, FILE *, (const char *cmd
, const char *mode
));
1186 _GL_CXXALIASWARN (popen
);
1188 # if @GNULIB_PCLOSE@ && __GNUC__ >= 11 && !defined popen
1189 /* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */
1190 _GL_FUNCDECL_SYS (popen
, FILE *,
1191 (const char *cmd
, const char *mode
)
1192 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose
, 1)
1193 _GL_ATTRIBUTE_MALLOC
);
1195 # if defined GNULIB_POSIXCHECK
1197 # if HAVE_RAW_DECL_POPEN
1198 _GL_WARN_ON_USE (popen
, "popen is buggy on some platforms - "
1199 "use gnulib module popen or pipe for more portability");
1204 #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
1205 # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
1206 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1207 # if defined __GNUC__ || defined __clang__
1208 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1209 /* Don't break __attribute__((format(printf,M,N))). */
1210 # define printf __printf__
1212 # if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
1213 _GL_FUNCDECL_RPL_1 (__printf__
, int,
1214 (const char *restrict format
, ...)
1215 __asm__ (@ASM_SYMBOL_PREFIX@
1216 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf
))
1217 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
1218 _GL_ARG_NONNULL ((1)));
1220 _GL_FUNCDECL_RPL_1 (__printf__
, int,
1221 (const char *restrict format
, ...)
1222 __asm__ (@ASM_SYMBOL_PREFIX@
1223 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf
))
1224 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
1225 _GL_ARG_NONNULL ((1)));
1227 _GL_CXXALIAS_RPL_1 (printf
, __printf__
, int, (const char *format
, ...));
1229 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1230 # define printf rpl_printf
1232 _GL_FUNCDECL_RPL (printf
, int,
1233 (const char *restrict format
, ...)
1234 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
1235 _GL_ARG_NONNULL ((1)));
1236 _GL_CXXALIAS_RPL (printf
, int, (const char *restrict format
, ...));
1238 # define GNULIB_overrides_printf 1
1240 _GL_CXXALIAS_SYS (printf
, int, (const char *restrict format
, ...));
1243 _GL_CXXALIASWARN (printf
);
1246 #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1247 # if !GNULIB_overrides_printf
1250 /* Assume printf is always declared. */
1251 _GL_WARN_ON_USE (printf
, "printf is not always POSIX compliant - "
1252 "use gnulib module printf-posix for portable "
1253 "POSIX compliance");
1257 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
1258 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1260 # define putc rpl_fputc
1262 _GL_FUNCDECL_RPL (fputc
, int, (int c
, FILE *stream
) _GL_ARG_NONNULL ((2)));
1263 _GL_CXXALIAS_RPL_1 (putc
, rpl_fputc
, int, (int c
, FILE *stream
));
1265 _GL_CXXALIAS_SYS (putc
, int, (int c
, FILE *stream
));
1268 _GL_CXXALIASWARN (putc
);
1272 #if @GNULIB_PUTCHAR@
1273 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
1274 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1276 # define putchar rpl_putchar
1278 _GL_FUNCDECL_RPL (putchar
, int, (int c
));
1279 _GL_CXXALIAS_RPL (putchar
, int, (int c
));
1281 _GL_CXXALIAS_SYS (putchar
, int, (int c
));
1284 _GL_CXXALIASWARN (putchar
);
1289 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
1290 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1292 # define puts rpl_puts
1294 _GL_FUNCDECL_RPL (puts
, int, (const char *string
) _GL_ARG_NONNULL ((1)));
1295 _GL_CXXALIAS_RPL (puts
, int, (const char *string
));
1297 _GL_CXXALIAS_SYS (puts
, int, (const char *string
));
1300 _GL_CXXALIASWARN (puts
);
1304 #if @GNULIB_MDA_PUTW@
1305 /* On native Windows, map 'putw' to '_putw', so that -loldnames is not
1306 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1307 platforms by defining GNULIB_NAMESPACE::putw always. */
1308 # if defined _WIN32 && !defined __CYGWIN__
1309 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1313 _GL_CXXALIAS_MDA (putw
, int, (int w
, FILE *restrict stream
));
1315 # if @HAVE_DECL_PUTW@
1316 # if defined __APPLE__ && defined __MACH__
1317 /* The presence of the declaration depends on _POSIX_C_SOURCE. */
1318 _GL_FUNCDECL_SYS (putw
, int, (int w
, FILE *restrict stream
));
1320 _GL_CXXALIAS_SYS (putw
, int, (int w
, FILE *restrict stream
));
1324 _GL_CXXALIASWARN (putw
);
1329 # if @REPLACE_REMOVE@
1330 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1332 # define remove rpl_remove
1334 _GL_FUNCDECL_RPL (remove
, int, (const char *name
) _GL_ARG_NONNULL ((1)));
1335 _GL_CXXALIAS_RPL (remove
, int, (const char *name
));
1337 _GL_CXXALIAS_SYS (remove
, int, (const char *name
));
1340 _GL_CXXALIASWARN (remove
);
1342 #elif defined GNULIB_POSIXCHECK
1344 /* Assume remove is always declared. */
1345 _GL_WARN_ON_USE (remove
, "remove cannot handle directories on some platforms - "
1346 "use gnulib module remove for more portability");
1350 # if @REPLACE_RENAME@
1351 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1353 # define rename rpl_rename
1355 _GL_FUNCDECL_RPL (rename
, int,
1356 (const char *old_filename
, const char *new_filename
)
1357 _GL_ARG_NONNULL ((1, 2)));
1358 _GL_CXXALIAS_RPL (rename
, int,
1359 (const char *old_filename
, const char *new_filename
));
1361 _GL_CXXALIAS_SYS (rename
, int,
1362 (const char *old_filename
, const char *new_filename
));
1365 _GL_CXXALIASWARN (rename
);
1367 #elif defined GNULIB_POSIXCHECK
1369 /* Assume rename is always declared. */
1370 _GL_WARN_ON_USE (rename
, "rename is buggy on some platforms - "
1371 "use gnulib module rename for more portability");
1374 #if @GNULIB_RENAMEAT@
1375 # if @REPLACE_RENAMEAT@
1376 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1378 # define renameat rpl_renameat
1380 _GL_FUNCDECL_RPL (renameat
, int,
1381 (int fd1
, char const *file1
, int fd2
, char const *file2
)
1382 _GL_ARG_NONNULL ((2, 4)));
1383 _GL_CXXALIAS_RPL (renameat
, int,
1384 (int fd1
, char const *file1
, int fd2
, char const *file2
));
1386 # if !@HAVE_RENAMEAT@
1387 _GL_FUNCDECL_SYS (renameat
, int,
1388 (int fd1
, char const *file1
, int fd2
, char const *file2
)
1389 _GL_ARG_NONNULL ((2, 4)));
1391 _GL_CXXALIAS_SYS (renameat
, int,
1392 (int fd1
, char const *file1
, int fd2
, char const *file2
));
1394 _GL_CXXALIASWARN (renameat
);
1395 #elif defined GNULIB_POSIXCHECK
1397 # if HAVE_RAW_DECL_RENAMEAT
1398 _GL_WARN_ON_USE (renameat
, "renameat is not portable - "
1399 "use gnulib module renameat for portability");
1404 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
1405 # if defined __GNUC__ || defined __clang__
1406 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1408 /* Don't break __attribute__((format(scanf,M,N))). */
1409 # define scanf __scanf__
1411 _GL_FUNCDECL_RPL_1 (__scanf__
, int,
1412 (const char *restrict format
, ...)
1413 __asm__ (@ASM_SYMBOL_PREFIX@
1414 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf
))
1415 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1416 _GL_ARG_NONNULL ((1)));
1417 _GL_CXXALIAS_RPL_1 (scanf
, __scanf__
, int, (const char *restrict format
, ...));
1419 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1421 # define scanf rpl_scanf
1423 _GL_FUNCDECL_RPL (scanf
, int, (const char *restrict format
, ...)
1424 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1425 _GL_ARG_NONNULL ((1)));
1426 _GL_CXXALIAS_RPL (scanf
, int, (const char *restrict format
, ...));
1429 _GL_CXXALIAS_SYS (scanf
, int, (const char *restrict format
, ...));
1432 _GL_CXXALIASWARN (scanf
);
1436 #if @GNULIB_SNPRINTF@
1437 # if @REPLACE_SNPRINTF@
1438 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1439 # define snprintf rpl_snprintf
1441 # define GNULIB_overrides_snprintf 1
1442 _GL_FUNCDECL_RPL (snprintf
, int,
1443 (char *restrict str
, size_t size
,
1444 const char *restrict format
, ...)
1445 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
1446 _GL_ARG_NONNULL ((3)));
1447 _GL_CXXALIAS_RPL (snprintf
, int,
1448 (char *restrict str
, size_t size
,
1449 const char *restrict format
, ...));
1451 # if !@HAVE_DECL_SNPRINTF@
1452 _GL_FUNCDECL_SYS (snprintf
, int,
1453 (char *restrict str
, size_t size
,
1454 const char *restrict format
, ...)
1455 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
1456 _GL_ARG_NONNULL ((3)));
1458 _GL_CXXALIAS_SYS (snprintf
, int,
1459 (char *restrict str
, size_t size
,
1460 const char *restrict format
, ...));
1463 _GL_CXXALIASWARN (snprintf
);
1465 #elif defined GNULIB_POSIXCHECK
1467 # if HAVE_RAW_DECL_SNPRINTF
1468 _GL_WARN_ON_USE (snprintf
, "snprintf is unportable - "
1469 "use gnulib module snprintf for portability");
1473 /* Some people would argue that all sprintf uses should be warned about
1474 (for example, OpenBSD issues a link warning for it),
1475 since it can cause security holes due to buffer overruns.
1476 However, we believe that sprintf can be used safely, and is more
1477 efficient than snprintf in those safe cases; and as proof of our
1478 belief, we use sprintf in several gnulib modules. So this header
1479 intentionally avoids adding a warning to sprintf except when
1480 GNULIB_POSIXCHECK is defined. */
1482 #if @GNULIB_SPRINTF_POSIX@
1483 # if @REPLACE_SPRINTF@
1484 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1485 # define sprintf rpl_sprintf
1487 # define GNULIB_overrides_sprintf 1
1488 _GL_FUNCDECL_RPL (sprintf
, int,
1489 (char *restrict str
, const char *restrict format
, ...)
1490 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1491 _GL_ARG_NONNULL ((1, 2)));
1492 _GL_CXXALIAS_RPL (sprintf
, int,
1493 (char *restrict str
, const char *restrict format
, ...));
1495 _GL_CXXALIAS_SYS (sprintf
, int,
1496 (char *restrict str
, const char *restrict format
, ...));
1499 _GL_CXXALIASWARN (sprintf
);
1501 #elif defined GNULIB_POSIXCHECK
1503 /* Assume sprintf is always declared. */
1504 _GL_WARN_ON_USE (sprintf
, "sprintf is not always POSIX compliant - "
1505 "use gnulib module sprintf-posix for portable "
1506 "POSIX compliance");
1509 #if @GNULIB_MDA_TEMPNAM@
1510 /* On native Windows, map 'tempnam' to '_tempnam', so that -loldnames is not
1511 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1512 platforms by defining GNULIB_NAMESPACE::tempnam always. */
1513 # if defined _WIN32 && !defined __CYGWIN__
1514 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1516 # define tempnam _tempnam
1518 _GL_CXXALIAS_MDA (tempnam
, char *, (const char *dir
, const char *prefix
));
1520 _GL_CXXALIAS_SYS (tempnam
, char *, (const char *dir
, const char *prefix
));
1522 _GL_CXXALIASWARN (tempnam
);
1525 #if @GNULIB_TMPFILE@
1526 # if @REPLACE_TMPFILE@
1527 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1528 # define tmpfile rpl_tmpfile
1530 _GL_FUNCDECL_RPL (tmpfile
, FILE *, (void)
1531 _GL_ATTRIBUTE_DEALLOC (fclose
, 1)
1532 _GL_ATTRIBUTE_MALLOC
);
1533 _GL_CXXALIAS_RPL (tmpfile
, FILE *, (void));
1536 /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
1537 _GL_FUNCDECL_SYS (tmpfile
, FILE *, (void)
1538 _GL_ATTRIBUTE_DEALLOC (fclose
, 1)
1539 _GL_ATTRIBUTE_MALLOC
);
1541 _GL_CXXALIAS_SYS (tmpfile
, FILE *, (void));
1544 _GL_CXXALIASWARN (tmpfile
);
1547 # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile
1548 /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
1549 _GL_FUNCDECL_SYS (tmpfile
, FILE *, (void)
1550 _GL_ATTRIBUTE_DEALLOC (fclose
, 1)
1551 _GL_ATTRIBUTE_MALLOC
);
1553 # if defined GNULIB_POSIXCHECK
1555 # if HAVE_RAW_DECL_TMPFILE
1556 _GL_WARN_ON_USE (tmpfile
, "tmpfile is not usable on mingw - "
1557 "use gnulib module tmpfile for portability");
1562 #if @GNULIB_VASPRINTF@
1563 /* Write formatted output to a string dynamically allocated with malloc().
1564 If the memory allocation succeeds, store the address of the string in
1565 *RESULT and return the number of resulting bytes, excluding the trailing
1566 NUL. Upon memory allocation error, or some other error, return -1. */
1567 # if @REPLACE_VASPRINTF@
1568 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1569 # define asprintf rpl_asprintf
1571 # define GNULIB_overrides_asprintf
1572 _GL_FUNCDECL_RPL (asprintf
, int,
1573 (char **result
, const char *format
, ...)
1574 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1575 _GL_ARG_NONNULL ((1, 2)));
1576 _GL_CXXALIAS_RPL (asprintf
, int,
1577 (char **result
, const char *format
, ...));
1579 # if !@HAVE_VASPRINTF@
1580 _GL_FUNCDECL_SYS (asprintf
, int,
1581 (char **result
, const char *format
, ...)
1582 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1583 _GL_ARG_NONNULL ((1, 2)));
1585 _GL_CXXALIAS_SYS (asprintf
, int,
1586 (char **result
, const char *format
, ...));
1588 _GL_CXXALIASWARN (asprintf
);
1589 # if @REPLACE_VASPRINTF@
1590 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1591 # define vasprintf rpl_vasprintf
1593 # define GNULIB_overrides_vasprintf 1
1594 _GL_FUNCDECL_RPL (vasprintf
, int,
1595 (char **result
, const char *format
, va_list args
)
1596 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1597 _GL_ARG_NONNULL ((1, 2)));
1598 _GL_CXXALIAS_RPL (vasprintf
, int,
1599 (char **result
, const char *format
, va_list args
));
1601 # if !@HAVE_VASPRINTF@
1602 _GL_FUNCDECL_SYS (vasprintf
, int,
1603 (char **result
, const char *format
, va_list args
)
1604 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1605 _GL_ARG_NONNULL ((1, 2)));
1607 _GL_CXXALIAS_SYS (vasprintf
, int,
1608 (char **result
, const char *format
, va_list args
));
1610 _GL_CXXALIASWARN (vasprintf
);
1613 #if @GNULIB_VDPRINTF@
1614 # if @REPLACE_VDPRINTF@
1615 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1616 # define vdprintf rpl_vdprintf
1618 _GL_FUNCDECL_RPL (vdprintf
, int,
1619 (int fd
, const char *restrict format
, va_list args
)
1620 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1621 _GL_ARG_NONNULL ((2)));
1622 _GL_CXXALIAS_RPL (vdprintf
, int,
1623 (int fd
, const char *restrict format
, va_list args
));
1625 # if !@HAVE_VDPRINTF@
1626 _GL_FUNCDECL_SYS (vdprintf
, int,
1627 (int fd
, const char *restrict format
, va_list args
)
1628 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1629 _GL_ARG_NONNULL ((2)));
1631 /* Need to cast, because on Solaris, the third parameter will likely be
1633 _GL_CXXALIAS_SYS_CAST (vdprintf
, int,
1634 (int fd
, const char *restrict format
, va_list args
));
1637 _GL_CXXALIASWARN (vdprintf
);
1639 #elif defined GNULIB_POSIXCHECK
1641 # if HAVE_RAW_DECL_VDPRINTF
1642 _GL_WARN_ON_USE (vdprintf
, "vdprintf is unportable - "
1643 "use gnulib module vdprintf for portability");
1647 #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
1648 # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
1649 || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1650 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1651 # define vfprintf rpl_vfprintf
1653 # define GNULIB_overrides_vfprintf 1
1654 # if @GNULIB_VFPRINTF_POSIX@
1655 _GL_FUNCDECL_RPL (vfprintf
, int,
1657 const char *restrict format
, va_list args
)
1658 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1659 _GL_ARG_NONNULL ((1, 2)));
1661 _GL_FUNCDECL_RPL (vfprintf
, int,
1663 const char *restrict format
, va_list args
)
1664 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
1665 _GL_ARG_NONNULL ((1, 2)));
1667 _GL_CXXALIAS_RPL (vfprintf
, int,
1669 const char *restrict format
, va_list args
));
1671 /* Need to cast, because on Solaris, the third parameter is
1673 and GCC's fixincludes did not change this to __gnuc_va_list. */
1674 _GL_CXXALIAS_SYS_CAST (vfprintf
, int,
1676 const char *restrict format
, va_list args
));
1679 _GL_CXXALIASWARN (vfprintf
);
1682 #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1683 # if !GNULIB_overrides_vfprintf
1686 /* Assume vfprintf is always declared. */
1687 _GL_WARN_ON_USE (vfprintf
, "vfprintf is not always POSIX compliant - "
1688 "use gnulib module vfprintf-posix for portable "
1689 "POSIX compliance");
1692 #if @GNULIB_VFSCANF@
1693 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
1694 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1696 # define vfscanf rpl_vfscanf
1698 _GL_FUNCDECL_RPL (vfscanf
, int,
1699 (FILE *restrict stream
,
1700 const char *restrict format
, va_list args
)
1701 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
1702 _GL_ARG_NONNULL ((1, 2)));
1703 _GL_CXXALIAS_RPL (vfscanf
, int,
1704 (FILE *restrict stream
,
1705 const char *restrict format
, va_list args
));
1707 _GL_CXXALIAS_SYS (vfscanf
, int,
1708 (FILE *restrict stream
,
1709 const char *restrict format
, va_list args
));
1712 _GL_CXXALIASWARN (vfscanf
);
1716 #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
1717 # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
1718 || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1719 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1720 # define vprintf rpl_vprintf
1722 # define GNULIB_overrides_vprintf 1
1723 # if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
1724 _GL_FUNCDECL_RPL (vprintf
, int, (const char *restrict format
, va_list args
)
1725 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
1726 _GL_ARG_NONNULL ((1)));
1728 _GL_FUNCDECL_RPL (vprintf
, int, (const char *restrict format
, va_list args
)
1729 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
1730 _GL_ARG_NONNULL ((1)));
1732 _GL_CXXALIAS_RPL (vprintf
, int, (const char *restrict format
, va_list args
));
1734 /* Need to cast, because on Solaris, the second parameter is
1736 and GCC's fixincludes did not change this to __gnuc_va_list. */
1737 _GL_CXXALIAS_SYS_CAST (vprintf
, int,
1738 (const char *restrict format
, va_list args
));
1741 _GL_CXXALIASWARN (vprintf
);
1744 #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1745 # if !GNULIB_overrides_vprintf
1748 /* Assume vprintf is always declared. */
1749 _GL_WARN_ON_USE (vprintf
, "vprintf is not always POSIX compliant - "
1750 "use gnulib module vprintf-posix for portable "
1751 "POSIX compliance");
1755 # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
1756 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1758 # define vscanf rpl_vscanf
1760 _GL_FUNCDECL_RPL (vscanf
, int, (const char *restrict format
, va_list args
)
1761 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
1762 _GL_ARG_NONNULL ((1)));
1763 _GL_CXXALIAS_RPL (vscanf
, int, (const char *restrict format
, va_list args
));
1765 _GL_CXXALIAS_SYS (vscanf
, int, (const char *restrict format
, va_list args
));
1768 _GL_CXXALIASWARN (vscanf
);
1772 #if @GNULIB_VSNPRINTF@
1773 # if @REPLACE_VSNPRINTF@
1774 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1775 # define vsnprintf rpl_vsnprintf
1777 # define GNULIB_overrides_vsnprintf 1
1778 _GL_FUNCDECL_RPL (vsnprintf
, int,
1779 (char *restrict str
, size_t size
,
1780 const char *restrict format
, va_list args
)
1781 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
1782 _GL_ARG_NONNULL ((3)));
1783 _GL_CXXALIAS_RPL (vsnprintf
, int,
1784 (char *restrict str
, size_t size
,
1785 const char *restrict format
, va_list args
));
1787 # if !@HAVE_DECL_VSNPRINTF@
1788 _GL_FUNCDECL_SYS (vsnprintf
, int,
1789 (char *restrict str
, size_t size
,
1790 const char *restrict format
, va_list args
)
1791 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
1792 _GL_ARG_NONNULL ((3)));
1794 _GL_CXXALIAS_SYS (vsnprintf
, int,
1795 (char *restrict str
, size_t size
,
1796 const char *restrict format
, va_list args
));
1799 _GL_CXXALIASWARN (vsnprintf
);
1801 #elif defined GNULIB_POSIXCHECK
1803 # if HAVE_RAW_DECL_VSNPRINTF
1804 _GL_WARN_ON_USE (vsnprintf
, "vsnprintf is unportable - "
1805 "use gnulib module vsnprintf for portability");
1809 #if @GNULIB_VSPRINTF_POSIX@
1810 # if @REPLACE_VSPRINTF@
1811 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1812 # define vsprintf rpl_vsprintf
1814 # define GNULIB_overrides_vsprintf 1
1815 _GL_FUNCDECL_RPL (vsprintf
, int,
1816 (char *restrict str
,
1817 const char *restrict format
, va_list args
)
1818 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1819 _GL_ARG_NONNULL ((1, 2)));
1820 _GL_CXXALIAS_RPL (vsprintf
, int,
1821 (char *restrict str
,
1822 const char *restrict format
, va_list args
));
1824 /* Need to cast, because on Solaris, the third parameter is
1826 and GCC's fixincludes did not change this to __gnuc_va_list. */
1827 _GL_CXXALIAS_SYS_CAST (vsprintf
, int,
1828 (char *restrict str
,
1829 const char *restrict format
, va_list args
));
1832 _GL_CXXALIASWARN (vsprintf
);
1834 #elif defined GNULIB_POSIXCHECK
1836 /* Assume vsprintf is always declared. */
1837 _GL_WARN_ON_USE (vsprintf
, "vsprintf is not always POSIX compliant - "
1838 "use gnulib module vsprintf-posix for portable "
1839 "POSIX compliance");
1842 #endif /* _@GUARD_PREFIX@_STDIO_H */
1843 #endif /* _@GUARD_PREFIX@_STDIO_H */