Improve *printf warning condition.
[gnulib.git] / lib / stdio.in.h
1 /* A GNU-like <stdio.h>.
2
3    Copyright (C) 2004, 2007-2010 Free Software Foundation, Inc.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9
10    This program 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 General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 #if __GNUC__ >= 3
20 @PRAGMA_SYSTEM_HEADER@
21 #endif
22
23 #if defined __need_FILE || defined __need___FILE
24 /* Special invocation convention inside glibc header files.  */
25
26 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
27
28 #else
29 /* Normal invocation convention.  */
30
31 #ifndef _GL_STDIO_H
32
33 /* The include_next requires a split double-inclusion guard.  */
34 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
35
36 #ifndef _GL_STDIO_H
37 #define _GL_STDIO_H
38
39 /* Get va_list.  Needed on many systems, including glibc 2.8.  */
40 #include <stdarg.h>
41
42 #include <stddef.h>
43
44 /* Get off_t and ssize_t.  Needed on many systems, including glibc 2.8.  */
45 #include <sys/types.h>
46
47 #ifndef __attribute__
48 /* The __attribute__ feature is available in gcc versions 2.5 and later.
49    The __-protected variants of the attributes 'format' and 'printf' are
50    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
51    We enable __attribute__ only if these are supported too, because
52    gnulib and libintl do '#define printf __printf__' when they override
53    the 'printf' function.  */
54 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
55 #  define __attribute__(Spec)   /* empty */
56 # endif
57 #endif
58
59
60 /* The definition of _GL_ARG_NONNULL is copied here.  */
61
62 /* The definition of _GL_WARN_ON_USE is copied here.  */
63
64
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68
69 #if @GNULIB_DPRINTF@
70 # if @REPLACE_DPRINTF@
71 #  define dprintf rpl_dprintf
72 # endif
73 # if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@
74 extern int dprintf (int fd, const char *format, ...)
75        __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((2));
76 # endif
77 #elif defined GNULIB_POSIXCHECK
78 # undef dprintf
79 # if HAVE_RAW_DECL_DPRINTF
80 _GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
81                  "use gnulib module dprintf for portability");
82 # endif
83 #endif
84
85 #if @GNULIB_FCLOSE@
86 # if @REPLACE_FCLOSE@
87 #  define fclose rpl_fclose
88   /* Close STREAM and its underlying file descriptor.  */
89 extern int fclose (FILE *stream) _GL_ARG_NONNULL ((1));
90 # endif
91 #elif defined GNULIB_POSIXCHECK
92 # undef fclose
93 /* Assume fclose is always declared.  */
94 _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
95                  "use gnulib module fclose for portable POSIX compliance");
96 #endif
97
98 #if @GNULIB_FFLUSH@
99 # if @REPLACE_FFLUSH@
100 #  define fflush rpl_fflush
101   /* Flush all pending data on STREAM according to POSIX rules.  Both
102      output and seekable input streams are supported.
103      Note! LOSS OF DATA can occur if fflush is applied on an input stream
104      that is _not_seekable_ or on an update stream that is _not_seekable_
105      and in which the most recent operation was input.  Seekability can
106      be tested with lseek(fileno(fp),0,SEEK_CUR).  */
107   extern int fflush (FILE *gl_stream);
108 # endif
109 #elif defined GNULIB_POSIXCHECK
110 # undef fflush
111 /* Assume fflush is always declared.  */
112 _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
113                  "use gnulib module fflush for portable POSIX compliance");
114 #endif
115
116 /* It is very rare that the developer ever has full control of stdin,
117    so any use of gets warrants an unconditional warning.  Assume it is
118    always declared, since it is required by C89.  */
119 #undef gets
120 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
121
122 #if @GNULIB_FOPEN@
123 # if @REPLACE_FOPEN@
124 #  undef fopen
125 #  define fopen rpl_fopen
126 extern FILE * fopen (const char *filename, const char *mode)
127      _GL_ARG_NONNULL ((1, 2));
128 # endif
129 #elif defined GNULIB_POSIXCHECK
130 # undef fopen
131 /* Assume fopen is always declared.  */
132 _GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - "
133                  "use gnulib module fopen for portability");
134 #endif
135
136 #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
137 # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
138      || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
139 #  define fprintf rpl_fprintf
140 #  define GNULIB_overrides_fprintf 1
141 extern int fprintf (FILE *fp, const char *format, ...)
142        __attribute__ ((__format__ (__printf__, 2, 3)))
143        _GL_ARG_NONNULL ((1, 2));
144 # endif
145 #endif
146 #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
147 # if !GNULIB_overrides_fprintf
148 #  undef fprintf
149 # endif
150 /* Assume fprintf is always declared.  */
151 _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
152                  "use gnulib module fprintf-posix for portable "
153                  "POSIX compliance");
154 #endif
155
156 #if @GNULIB_FPURGE@
157 # if @REPLACE_FPURGE@
158 #  define fpurge rpl_fpurge
159 # endif
160 # if @REPLACE_FPURGE@ || !@HAVE_DECL_FPURGE@
161   /* Discard all pending buffered I/O data on STREAM.
162      STREAM must not be wide-character oriented.
163      When discarding pending output, the file position is set back to where it
164      was before the write calls.  When discarding pending input, the file
165      position is advanced to match the end of the previously read input.
166      Return 0 if successful.  Upon error, return -1 and set errno.  */
167   extern int fpurge (FILE *gl_stream) _GL_ARG_NONNULL ((1));
168 # endif
169 #elif defined GNULIB_POSIXCHECK
170 # undef fpurge
171 # if HAVE_RAW_DECL_FPURGE
172 _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
173                  "use gnulib module fpurge for portability");
174 # endif
175 #endif
176
177 #if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
178 # undef fputc
179 # define fputc rpl_fputc
180 extern int fputc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
181 #endif
182
183 #if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
184 # undef fputs
185 # define fputs rpl_fputs
186 extern int fputs (const char *string, FILE *stream) _GL_ARG_NONNULL ((1, 2));
187 #endif
188
189 #if @GNULIB_FREOPEN@
190 # if @REPLACE_FREOPEN@
191 #  undef freopen
192 #  define freopen rpl_freopen
193 extern FILE * freopen (const char *filename, const char *mode, FILE *stream)
194      _GL_ARG_NONNULL ((2, 3));
195 # endif
196 #elif defined GNULIB_POSIXCHECK
197 # undef freopen
198 /* Assume freopen is always declared.  */
199 _GL_WARN_ON_USE (freopen, "freopen on Win32 platforms is not POSIX compatible - "
200                  "use gnulib module freopen for portability");
201 #endif
202
203
204 /* Set up the following warnings, based on which modules are in use.
205    GNU Coding Standards discourage the use of fseek, since it imposes
206    an arbitrary limitation on some 32-bit hosts.  Remember that the
207    fseek module depends on the fseeko module, so we only have three
208    cases to consider:
209
210    1. The developer is not using either module.  Issue a warning under
211    GNULIB_POSIXCHECK for both functions, to remind them that both
212    functions have bugs on some systems.  _GL_NO_LARGE_FILES has no
213    impact on this warning.
214
215    2. The developer is using both modules.  They may be unaware of the
216    arbitrary limitations of fseek, so issue a warning under
217    GNULIB_POSIXCHECK.  On the other hand, they may be using both
218    modules intentionally, so the developer can define
219    _GL_NO_LARGE_FILES in the compilation units where the use of fseek
220    is safe, to silence the warning.
221
222    3. The developer is using the fseeko module, but not fseek.  Gnulib
223    guarantees that fseek will still work around platform bugs in that
224    case, but we presume that the developer is aware of the pitfalls of
225    fseek and was trying to avoid it, so issue a warning even when
226    GNULIB_POSIXCHECK is undefined.  Again, _GL_NO_LARGE_FILES can be
227    defined to silence the warning in particular compilation units.
228
229    Most gnulib clients that perform stream operations should fall into
230    category 3.  */
231
232 #if @GNULIB_FSEEK@
233 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
234 #  define _GL_FSEEK_WARN /* Category 2, above.  */
235 #  undef fseek
236 # endif
237 # if @REPLACE_FSEEK@
238 #  undef fseek
239 #  define fseek rpl_fseek
240 extern int fseek (FILE *fp, long offset, int whence) _GL_ARG_NONNULL ((1));
241 # endif
242 #endif
243
244 #if @GNULIB_FSEEKO@
245 # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
246 #  define _GL_FSEEK_WARN /* Category 3, above.  */
247 #  undef fseek
248 # endif
249 # if @REPLACE_FSEEKO@
250 /* Provide fseek, fseeko functions that are aware of a preceding
251    fflush(), and which detect pipes.  */
252 #  undef fseeko
253 #  define fseeko rpl_fseeko
254 extern int fseeko (FILE *fp, off_t offset, int whence) _GL_ARG_NONNULL ((1));
255 #  if !@GNULIB_FSEEK@
256 #   undef fseek
257 #   define fseek rpl_fseek
258 static inline int _GL_ARG_NONNULL ((1))
259 rpl_fseek (FILE *fp, long offset, int whence)
260 {
261   return fseeko (fp, offset, whence);
262 }
263 #  endif
264 # endif
265 #elif defined GNULIB_POSIXCHECK
266 # define _GL_FSEEK_WARN /* Category 1, above.  */
267 # undef fseek
268 # undef fseeko
269 # if HAVE_RAW_DECL_FSEEKO
270 _GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
271                  "use gnulib module fseeko for portability");
272 # endif
273 #endif
274
275 #ifdef _GL_FSEEK_WARN
276 # undef _GL_FSEEK_WARN
277 /* Here, either fseek is undefined (but C89 guarantees that it is
278    declared), or it is defined as rpl_fseek (declared above).  */
279 _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
280                  "on 32-bit platforms - "
281                  "use fseeko function for handling of large files");
282 #endif
283
284
285 /* ftell, ftello.  See the comments on fseek/fseeko.  */
286
287 #if @GNULIB_FTELL@
288 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
289 #  define _GL_FTELL_WARN /* Category 2, above.  */
290 #  undef ftell
291 # endif
292 # if @REPLACE_FTELL@
293 #  undef ftell
294 #  define ftell rpl_ftell
295 extern long ftell (FILE *fp) _GL_ARG_NONNULL ((1));
296 # endif
297 #endif
298
299 #if @GNULIB_FTELLO@
300 # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
301 #  define _GL_FTELL_WARN /* Category 3, above.  */
302 #  undef ftell
303 # endif
304 # if @REPLACE_FTELLO@
305 #  undef ftello
306 #  define ftello rpl_ftello
307 extern off_t ftello (FILE *fp) _GL_ARG_NONNULL ((1));
308 #  if !@GNULIB_FTELL@
309 #   undef ftell
310 #   define ftell rpl_ftell
311 static inline long _GL_ARG_NONNULL ((1))
312 rpl_ftell (FILE *f)
313 {
314   return ftello (f);
315 }
316 #  endif
317 # endif
318 #elif defined GNULIB_POSIXCHECK
319 # define _GL_FTELL_WARN /* Category 1, above.  */
320 # undef ftell
321 # undef ftello
322 # if HAVE_RAW_DECL_FTELLO
323 _GL_WARN_ON_USE (ftello, "ftello is unportable - "
324                  "use gnulib module ftello for portability");
325 # endif
326 #endif
327
328 #ifdef _GL_FTELL_WARN
329 # undef _GL_FTELL_WARN
330 /* Here, either ftell is undefined (but C89 guarantees that it is
331    declared), or it is defined as rpl_ftell (declared above).  */
332 _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
333                  "on 32-bit platforms - "
334                  "use ftello function for handling of large files");
335 #endif
336
337
338 #if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
339 # undef fwrite
340 # define fwrite rpl_fwrite
341 extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
342      _GL_ARG_NONNULL ((1, 4));
343 #endif
344
345 #if @GNULIB_GETDELIM@
346 # if @REPLACE_GETDELIM@
347 #  undef getdelim
348 #  define getdelim rpl_getdelim
349 # endif
350 # if !@HAVE_DECL_GETDELIM@ || @REPLACE_GETDELIM@
351 /* Read input, up to (and including) the next occurrence of DELIMITER, from
352    STREAM, store it in *LINEPTR (and NUL-terminate it).
353    *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
354    bytes of space.  It is realloc'd as necessary.
355    Return the number of bytes read and stored at *LINEPTR (not including the
356    NUL terminator), or -1 on error or EOF.  */
357 extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
358                          FILE *stream)
359      _GL_ARG_NONNULL ((1, 2, 4));
360 # endif
361 #elif defined GNULIB_POSIXCHECK
362 # undef getdelim
363 # if HAVE_RAW_DECL_GETDELIM
364 _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
365                  "use gnulib module getdelim for portability");
366 # endif
367 #endif
368
369 #if @GNULIB_GETLINE@
370 # if @REPLACE_GETLINE@
371 #  undef getline
372 #  define getline rpl_getline
373 # endif
374 # if !@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@
375 /* Read a line, up to (and including) the next newline, from STREAM, store it
376    in *LINEPTR (and NUL-terminate it).
377    *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
378    bytes of space.  It is realloc'd as necessary.
379    Return the number of bytes read and stored at *LINEPTR (not including the
380    NUL terminator), or -1 on error or EOF.  */
381 extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream)
382      _GL_ARG_NONNULL ((1, 2, 3));
383 # endif
384 #elif defined GNULIB_POSIXCHECK
385 # undef getline
386 # if HAVE_RAW_DECL_GETLINE
387 _GL_WARN_ON_USE (getline, "getline is unportable - "
388                  "use gnulib module getline for portability");
389 # endif
390 #endif
391
392 #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
393 # if @REPLACE_OBSTACK_PRINTF@
394 #  define obstack_printf rpl_osbtack_printf
395 #  define obstack_vprintf rpl_obstack_vprintf
396 # endif
397 # if @REPLACE_OBSTACK_PRINTF@ || !@HAVE_DECL_OBSTACK_PRINTF@
398   struct obstack;
399   /* Grow an obstack with formatted output.  Return the number of
400      bytes added to OBS.  No trailing nul byte is added, and the
401      object should be closed with obstack_finish before use.  Upon
402      memory allocation error, call obstack_alloc_failed_handler.  Upon
403      other error, return -1.  */
404   extern int obstack_printf (struct obstack *obs, const char *format, ...)
405     __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2));
406   extern int obstack_vprintf (struct obstack *obs, const char *format,
407                               va_list args)
408     __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
409 # endif
410 #endif
411
412 #if @GNULIB_PERROR@
413 # if @REPLACE_PERROR@
414 #  define perror rpl_perror
415 /* Print a message to standard error, describing the value of ERRNO,
416    (if STRING is not NULL and not empty) prefixed with STRING and ": ",
417    and terminated with a newline.  */
418 extern void perror (const char *string);
419 # endif
420 #elif defined GNULIB_POSIXCHECK
421 # undef perror
422 /* Assume perror is always declared.  */
423 _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
424                  "use gnulib module perror for portability");
425 #endif
426
427 #if @GNULIB_POPEN@
428 # if @REPLACE_POPEN@
429 #  undef popen
430 #  define popen rpl_popen
431 extern FILE *popen (const char *cmd, const char *mode)
432      _GL_ARG_NONNULL ((1, 2));
433 # endif
434 #elif defined GNULIB_POSIXCHECK
435 # undef popen
436 # if HAVE_RAW_DECL_POPEN
437 _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
438                  "use gnulib module popen or pipe for more portability");
439 # endif
440 #endif
441
442 #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
443 # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
444      || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
445 /* Don't break __attribute__((format(printf,M,N))).  */
446 #  define printf __printf__
447 #  define GNULIB_overrides_printf 1
448 extern int printf (const char *format, ...)
449        __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
450 # endif
451 #endif
452 #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
453 # if !GNULIB_overrides_printf
454 #  undef printf
455 # endif
456 /* Assume printf is always declared.  */
457 _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
458                  "use gnulib module printf-posix for portable "
459                  "POSIX compliance");
460 #endif
461
462 #if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
463 # undef putc
464 # define putc rpl_fputc
465 extern int putc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
466 #endif
467
468 #if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
469 # undef putchar
470 # define putchar rpl_putchar
471 extern int putchar (int c);
472 #endif
473
474 #if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
475 # undef puts
476 # define puts rpl_puts
477 extern int puts (const char *string) _GL_ARG_NONNULL ((1));
478 #endif
479
480 #if @GNULIB_REMOVE@
481 # if @REPLACE_REMOVE@
482 #  undef remove
483 #  define remove rpl_remove
484 extern int remove (const char *name) _GL_ARG_NONNULL ((1));
485 # endif
486 #elif defined GNULIB_POSIXCHECK
487 # undef remove
488 /* Assume remove is always declared.  */
489 _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
490                  "use gnulib module remove for more portability");
491 #endif
492
493 #if @GNULIB_RENAME@
494 # if @REPLACE_RENAME@
495 #  undef rename
496 #  define rename rpl_rename
497 extern int rename (const char *old_filename, const char *new_filename)
498      _GL_ARG_NONNULL ((1, 2));
499 # endif
500 #elif defined GNULIB_POSIXCHECK
501 # undef rename
502 /* Assume rename is always declared.  */
503 _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
504                  "use gnulib module rename for more portability");
505 #endif
506
507 #if @GNULIB_RENAMEAT@
508 # if @REPLACE_RENAMEAT@
509 #  undef renameat
510 #  define renameat rpl_renameat
511 # endif
512 # if !@HAVE_RENAMEAT@ || @REPLACE_RENAMEAT@
513 extern int renameat (int fd1, char const *file1, int fd2, char const *file2)
514      _GL_ARG_NONNULL ((2, 4));
515 # endif
516 #elif defined GNULIB_POSIXCHECK
517 # undef renameat
518 # if HAVE_RAW_DECL_RENAMEAT
519 _GL_WARN_ON_USE (renameat, "renameat is not portable - "
520                  "use gnulib module renameat for portability");
521 # endif
522 #endif
523
524 #if @GNULIB_SNPRINTF@
525 # if @REPLACE_SNPRINTF@
526 #  define snprintf rpl_snprintf
527 # endif
528 # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
529 extern int snprintf (char *str, size_t size, const char *format, ...)
530        __attribute__ ((__format__ (__printf__, 3, 4)))
531        _GL_ARG_NONNULL ((3));
532 # endif
533 #elif defined GNULIB_POSIXCHECK
534 # undef snprintf
535 # if HAVE_RAW_DECL_SNPRINTF
536 _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
537                  "use gnulib module snprintf for portability");
538 # endif
539 #endif
540
541 /* Some people would argue that sprintf should be handled like gets
542    (for example, OpenBSD issues a link warning for both functions),
543    since both can cause security holes due to buffer overruns.
544    However, we believe that sprintf can be used safely, and is more
545    efficient than snprintf in those safe cases; and as proof of our
546    belief, we use sprintf in several gnulib modules.  So this header
547    intentionally avoids adding a warning to sprintf except when
548    GNULIB_POSIXCHECK is defined.  */
549
550 #if @GNULIB_SPRINTF_POSIX@
551 # if @REPLACE_SPRINTF@
552 #  define sprintf rpl_sprintf
553 extern int sprintf (char *str, const char *format, ...)
554        __attribute__ ((__format__ (__printf__, 2, 3)))
555        _GL_ARG_NONNULL ((1, 2));
556 # endif
557 #elif defined GNULIB_POSIXCHECK
558 # undef sprintf
559 /* Assume sprintf is always declared.  */
560 _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
561                  "use gnulib module sprintf-posix for portable "
562                  "POSIX compliance");
563 #endif
564
565 #if @GNULIB_VASPRINTF@
566 # if @REPLACE_VASPRINTF@
567 #  define asprintf rpl_asprintf
568 #  define vasprintf rpl_vasprintf
569 # endif
570 # if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@
571   /* Write formatted output to a string dynamically allocated with malloc().
572      If the memory allocation succeeds, store the address of the string in
573      *RESULT and return the number of resulting bytes, excluding the trailing
574      NUL.  Upon memory allocation error, or some other error, return -1.  */
575   extern int asprintf (char **result, const char *format, ...)
576     __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2));
577   extern int vasprintf (char **result, const char *format, va_list args)
578     __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
579 # endif
580 #endif
581
582 #if @GNULIB_VDPRINTF@
583 # if @REPLACE_VDPRINTF@
584 #  define vdprintf rpl_vdprintf
585 # endif
586 # if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@
587 extern int vdprintf (int fd, const char *format, va_list args)
588        __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((2));
589 # endif
590 #elif defined GNULIB_POSIXCHECK
591 # undef vdprintf
592 # if HAVE_RAW_DECL_VDPRINTF
593 _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
594                  "use gnulib module vdprintf for portability");
595 # endif
596 #endif
597
598 #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
599 # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
600      || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
601 #  define vfprintf rpl_vfprintf
602 #  define GNULIB_overrides_vfprintf 1
603 extern int vfprintf (FILE *fp, const char *format, va_list args)
604        __attribute__ ((__format__ (__printf__, 2, 0)))
605        _GL_ARG_NONNULL ((1, 2));
606 # endif
607 #endif
608 #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
609 # if !GNULIB_overrides_vfprintf
610 #  undef vfprintf
611 # endif
612 /* Assume vfprintf is always declared.  */
613 _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
614                  "use gnulib module vfprintf-posix for portable "
615                       "POSIX compliance");
616 #endif
617
618 #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
619 # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
620      || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
621 #  define vprintf rpl_vprintf
622 #  define GNULIB_overrides_vprintf 1
623 extern int vprintf (const char *format, va_list args)
624        __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1));
625 # endif
626 #endif
627 #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
628 # if !GNULIB_overrides_vprintf
629 #  undef vprintf
630 # endif
631 /* Assume vprintf is always declared.  */
632 _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
633                  "use gnulib module vprintf-posix for portable "
634                  "POSIX compliance");
635 #endif
636
637 #if @GNULIB_VSNPRINTF@
638 # if @REPLACE_VSNPRINTF@
639 #  define vsnprintf rpl_vsnprintf
640 # endif
641 # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
642 extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
643        __attribute__ ((__format__ (__printf__, 3, 0)))
644        _GL_ARG_NONNULL ((3));
645 # endif
646 #elif defined GNULIB_POSIXCHECK
647 # undef vsnprintf
648 # if HAVE_RAW_DECL_VSNPRINTF
649 _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
650                  "use gnulib module vsnprintf for portability");
651 # endif
652 #endif
653
654 #if @GNULIB_VSPRINTF_POSIX@
655 # if @REPLACE_VSPRINTF@
656 #  define vsprintf rpl_vsprintf
657 extern int vsprintf (char *str, const char *format, va_list args)
658        __attribute__ ((__format__ (__printf__, 2, 0)))
659        _GL_ARG_NONNULL ((1, 2));
660 # endif
661 #elif defined GNULIB_POSIXCHECK
662 # undef vsprintf
663 /* Assume vsprintf is always declared.  */
664 _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
665                  "use gnulib module vsprintf-posix for portable "
666                       "POSIX compliance");
667 #endif
668
669 #ifdef __cplusplus
670 }
671 #endif
672
673 #endif /* _GL_STDIO_H */
674 #endif /* _GL_STDIO_H */
675 #endif