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