xref: /llvm-project/libcxx/include/stdio.h (revision 902e62cf15229a4ef32d12cd4ee083e3a58c447b)
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 /*
11     stdio.h synopsis
12 
13 Macros:
14 
15     BUFSIZ
16     EOF
17     FILENAME_MAX
18     FOPEN_MAX
19     L_tmpnam
20     NULL
21     SEEK_CUR
22     SEEK_END
23     SEEK_SET
24     TMP_MAX
25     _IOFBF
26     _IOLBF
27     _IONBF
28     stderr
29     stdin
30     stdout
31 
32 Types:
33 
34 FILE
35 fpos_t
36 size_t
37 
38 int remove(const char* filename);
39 int rename(const char* old, const char* new);
40 FILE* tmpfile(void);
41 char* tmpnam(char* s);
42 int fclose(FILE* stream);
43 int fflush(FILE* stream);
44 FILE* fopen(const char* restrict filename, const char* restrict mode);
45 FILE* freopen(const char* restrict filename, const char * restrict mode,
46               FILE * restrict stream);
47 void setbuf(FILE* restrict stream, char* restrict buf);
48 int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size);
49 int fprintf(FILE* restrict stream, const char* restrict format, ...);
50 int fscanf(FILE* restrict stream, const char * restrict format, ...);
51 int printf(const char* restrict format, ...);
52 int scanf(const char* restrict format, ...);
53 int snprintf(char* restrict s, size_t n, const char* restrict format, ...);    // C99
54 int sprintf(char* restrict s, const char* restrict format, ...);
55 int sscanf(const char* restrict s, const char* restrict format, ...);
56 int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg);
57 int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg);  // C99
58 int vprintf(const char* restrict format, va_list arg);
59 int vscanf(const char* restrict format, va_list arg);                          // C99
60 int vsnprintf(char* restrict s, size_t n, const char* restrict format,         // C99
61               va_list arg);
62 int vsprintf(char* restrict s, const char* restrict format, va_list arg);
63 int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99
64 int fgetc(FILE* stream);
65 char* fgets(char* restrict s, int n, FILE* restrict stream);
66 int fputc(int c, FILE* stream);
67 int fputs(const char* restrict s, FILE* restrict stream);
68 int getc(FILE* stream);
69 int getchar(void);
70 char* gets(char* s);  // removed in C++14
71 int putc(int c, FILE* stream);
72 int putchar(int c);
73 int puts(const char* s);
74 int ungetc(int c, FILE* stream);
75 size_t fread(void* restrict ptr, size_t size, size_t nmemb,
76              FILE* restrict stream);
77 size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb,
78               FILE* restrict stream);
79 int fgetpos(FILE* restrict stream, fpos_t* restrict pos);
80 int fseek(FILE* stream, long offset, int whence);
81 int fsetpos(FILE*stream, const fpos_t* pos);
82 long ftell(FILE* stream);
83 void rewind(FILE* stream);
84 void clearerr(FILE* stream);
85 int feof(FILE* stream);
86 int ferror(FILE* stream);
87 void perror(const char* s);
88 */
89 
90 #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
91 #  include <__cxx03/stdio.h>
92 #else
93 #  include <__config>
94 
95 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
96 #    pragma GCC system_header
97 #  endif
98 
99 // The inclusion of the system's <stdio.h> is intentionally done once outside of any include
100 // guards because some code expects to be able to include the underlying system header multiple
101 // times to get different definitions based on the macros that are set before inclusion.
102 #  if __has_include_next(<stdio.h>)
103 #    include_next <stdio.h>
104 #  endif
105 
106 #  ifndef _LIBCPP_STDIO_H
107 #    define _LIBCPP_STDIO_H
108 
109 #    ifdef __cplusplus
110 
111 #      undef getc
112 #      undef putc
113 #      undef clearerr
114 #      undef feof
115 #      undef ferror
116 #      undef putchar
117 #      undef getchar
118 
119 #    endif // __cplusplus
120 #  endif   // _LIBCPP_STDIO_H
121 
122 #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
123